Suppose I have a query that returns the total monthly sales of individual products in my database: Is there a way to query various levels of specificity without creating many similar queries. For instance, If i enter Espresso for the product, leave out the milkoptions entry, and enter small for size, could I return all Small Espresso sales. Vice versa
Tag: sqlite
How to insert rows in SQLite using default values?
Update: Here is what I have learned from the answers below… SQLite supports defining default values on columns. However, it does not support any form of DEFAULT keyword or function in queries. So, …
Finding an ID not in another column
I’m working on a little SQL exercise, and am scratching my head an this problem. I am trying to find all the Employees to whom no other employee reports to. This is what the employees table looks …
Where clause in upsert conflict target
Suppose I have a table created like this: When attempting to insert a new row, there are three possibilties: No row for ‘name’ exists. The new row should be inserted. A row for ‘name’ exists that has a value of NULL. The existing row should be updated with the new value. A row for ‘name ‘ exists that has a
Create table with composite attribute/columns in sqlite3
I have to create a Table in the SQLite database, however, I am unable to find the syntax where I can define composite attribute/columns while creating the table.In this ER diagram, I have a composite attribute as a DateOfPurchase of the Bicycle So could some please help me with this, Thanks in advance. Answer See here: the last added field
Write a select query that displays “id” if a different “id” has same “panum”
The question i need to answer: “Display a list of academics that have collaborated with another academic on more than one paper. List individual pairs of academics on each line. List only their academic numbers. Do not list duplicate pairs. (e.g 56,113 and 113,56 are duplicate pairs)” So far iv been looking a way to write a query that displays
Find a list of all suppliers with orders from more than 615 different customers. Should return supplier name and customer count
Tables: Supplier: S_SUPPKEY, S_NAME Customer : C_CUSTKEY, C_NAME Orders : O_ORDERKEY, O_CUSTKEY Lineitem : L_ORDERKEY, L_SUPPKEY In the Lineitem table, there are many columns with the same ORDERKEY, …
How to convert a query into a nested query
How do I change this query into a nested query? The query and tables are listed below. tables goes as follows Nation : N_NATIONKEY, N_NAME Supplier : S_SUPPKEY, S_NAME, S_NATIONKEY Customer : C_CUSTKEY, C_NAME, C_NATIONKEY Orders: O_ORDERKEY, O_CUSTKEY Lineitem: L_ORDERKEY, L_SUPPKEY, L_QUANTITY, L_EXTENDEDPRICE, L_DISCOUNT Answer I’m not sure exactly what kind of nested join you’re looking for, but here is
Query works on SQLite but fails on SQL Server
The following query works for me in SQLite. But in SQL Server, it gives me an error. Invalid column name ‘VehId’. And the editor puts a red squiggly line under the last VehId (but not the first). As you might expect, Vehicles.Id is the primary key. I’m trying to find all foreign keys in Transactions that don’t reference any row
How to improve SQL query performance for HAVING (SQLite)
These 2 queriess are taking several minutes on tables of several millions rows (2 tables: torrents and dates). None of the columns are indexed I believe. I don’t know SQL well. Is there any way to …