Suppose have a schema for Suppliers, Catalogue and Parts and we are trying to figure out what suppliers supply all parts except one. Would this be the correct query? I’m unsure only because of that -…
How to delete records from a table if they don’t meet a condition in another table
I have two tables, company and company_name. company contains the columns: company_id(primary key) and company_name, while company_name contains the columns: company_id(foreign key from company table),…
Performance for Avg & Max in SQL
I want to decrease the query execution time for the following query. This query is taking around 1 min 20 secs for about 2k records. Numbers of records in table: 1348474 Number of records processed through where query: 25000 Number of records returned: 2152 I tried removing the AVG & MAX columns and it lo…
‘CREATE TABLE’ generates Run-time error ‘3290’
I have a syntax issue in the first CREATE TABLE statement. I’m receiving the following VBA error: Run-time error ‘3290’ The goal is to move the distinct data to a new table dependent on values in …
insert into two different tables from two different tables
When i try this, i got error “ORA-06550: line 2, column 48: PL/SQL: ORA-00926: missing VALUES keyword ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored”. I need to insert some values …
Efficient way for storing the feedbacks of a website in database
I am designing the database to store the feedback given by the users. I am using mariaDB. I am just wondering if my database design is efficient. Also, Can I improve it? We can have the following …
How to find the three greatest values in each category in PostgreSQL?
I am a SQL beginner. I have trouble on how to find the top 3 max values in each category. The question was “For order_ids in January 2006, what were the top (by revenue) 3 product_ids for each …
Violation of uniqueness in primary key when using inheritance
I’m using inheritance in PostgreSQL but there is a big problem while using it. I have a Parent table and 2 Child Tables and I don’tknow how to insert a data in these tables. The uniqueness of Parent …
how to pick the column with the highest value
I have a table with different possibilities of marital status (columns), how do I pick up the one with the highest value and keep the column name? For example, below is my original data set: data …
SQL – Calculating third column from previous two
I have just started SQL and have some difficulties in terms of thinking in this language. I have now a task where I need to create a new column in a table with values from previous columns. This …