I have a three tables: topics, sentences, and vocabulary. Sentences and vocabulary both have a belongsTo topic_id, but not all topics necessarily have both vocabulary and sentences. I want to get a count of all topics that have both sentences and vocabulary. I have it working if I do one table at a time: The …
subquery: is it good practise to use having clause to filter out rows of outer query that contains subquery’s null values
I have the following tables: SELECT * FROM medicine | id | name | producer | +—-+————-+———-+ | 1 | aspirin | pharma | | 2 | cetamol | tamiko | | 3 | brufen | …
iText PDF: the document has no pages
I’m trying to do a date range based filter to export a report into a PDF; however, when I click to export the PDF, I get the following message: ExceptionConverter: java.io.IOException: The document has no pages. Here’s my PDF class’ code: And here’s the code of the PDF generation butto…
How to update several rows with postgresql function
I have a table representing an object: id|field1|field2|field3 –|——|——|—— 1 | b | f | z 2 | q | q | q I want to pass several objects to pg function which will update …
Unable to grant all privileges to new user on Postgres
I’m creating a new user in a Postgres database (AWS RDS) and trying to grant all privileges on all tables in public schema of an existing database to that user. It is failing with below error. I even tried after logging in as the rds_superuser (postgres) and got the same error. psql (13.3, server 10.15)…
How to select a foreign key after narrowing down via Group By and Having in a subquery
I’ve got a unique problem. I’m querying a replicated database table cost_plan_breakdown, and the replication is known to have some duplicates due to issues with deleting records. I’m not the Admin so I’m trying to sidestep these duplicates as efficiently as possible. The table looks li…
Is the order of the result of SELECT DISTINCT … WHERE … “random”?
I have an SQL query that reads SELECT DISTINCT [NR] AS K_ID FROM [DB].[staging].[TABLE] WHERE [N]=1 and [O]=’XXX’ and [TYPE] in (‘1_P’, ‘2_I’) Since I’m saving the result in a CSV file (via Python …
Snowflake View nested calculation
I have to build a view by fetching data from 7-8 tables and then there are field which are calculated from other calculated fields. For example first calculation is if(indicator=‘H’, amount*20, amount)…
Oracle sql query to group two sets of dates if sequencials
I have the next table: EMPLOYEE CODE START_DATE END_DATE 02097368 F7H3 09/07/2018 20/10/2018 02097368 F7H3 21/10/2018 05/01/2019 02097368 F7H3 06/01/2019 12/01/2019 02097368 F7H3 13/01/2019 02/02/…
How to use a result from a SQL select to get records in another table?
I’m having a hard time with creating a Sql that pull data from three tables. Here are part of the structure of each table: Customer table: accnum integer name string address string Routeno …