Podcast
Questions and Answers
What is the SQL query to find the names of the ingredients supplied by a particular supplier?
What is the SQL query to find the names of the ingredients supplied by a particular supplier?
SELECT name FROM ingredients WHERE supplierid = 'S001';
What is the SQL query to find the names of all ingredients supplied by two suppliers?
What is the SQL query to find the names of all ingredients supplied by two suppliers?
SELECT name FROM ingredients WHERE supplierid = 'S001' OR supplierid = 'S002';
What is the SQL query to find the company names of all suppliers who provided an ingredient with an inventory of fewer than 50?
What is the SQL query to find the company names of all suppliers who provided an ingredient with an inventory of fewer than 50?
SELECT company_name FROM suppliers WHERE supplierid IN (SELECT supplierid FROM ingredients WHERE inventory < 50);
What is the SQL query to find the average unit price for all items provided by a supplier?
What is the SQL query to find the average unit price for all items provided by a supplier?
Signup and view all the answers
What is the SQL query to find the names of all suppliers referred to by another supplier?
What is the SQL query to find the names of all suppliers referred to by another supplier?
Signup and view all the answers
What is the SQL query to find all ingredients with an inventory within 25% of the average inventory of ingredients?
What is the SQL query to find all ingredients with an inventory within 25% of the average inventory of ingredients?
Signup and view all the answers
What is the SQL query to find the companies referred by a supplier and providing an ingredient in the milk food group?
What is the SQL query to find the companies referred by a supplier and providing an ingredient in the milk food group?
Signup and view all the answers
What is the SQL query to find the name and price for all items using an ingredient supplied by a supplier?
What is the SQL query to find the name and price for all items using an ingredient supplied by a supplier?
Signup and view all the answers
What is the SQL query to find the names and inventory values for all ingredients with an inventory value greater than the total inventory value of all ingredients provided by a supplier?
What is the SQL query to find the names and inventory values for all ingredients with an inventory value greater than the total inventory value of all ingredients provided by a supplier?
Signup and view all the answers
What is the SQL query to find all ingredients supplied by someone other than a particular supplier?
What is the SQL query to find all ingredients supplied by someone other than a particular supplier?
Signup and view all the answers
What is the SQL query to find the company name of small suppliers who do not provide any ingredients with large (>100) inventories?
What is the SQL query to find the company name of small suppliers who do not provide any ingredients with large (>100) inventories?
Signup and view all the answers
What is the SQL query to find the name and price of all items using an ingredient supplied by a particular supplier?
What is the SQL query to find the name and price of all items using an ingredient supplied by a particular supplier?
Signup and view all the answers
What is the SQL query to find all items that have a price greater than any salad item?
What is the SQL query to find all items that have a price greater than any salad item?
Signup and view all the answers
What is the SQL query to find the name of all ingredients supplied by two different suppliers?
What is the SQL query to find the name of all ingredients supplied by two different suppliers?
Signup and view all the answers
What is the SQL query to find all ingredients not supplied by two different suppliers?
What is the SQL query to find all ingredients not supplied by two different suppliers?
Signup and view all the answers
What is the SQL query to find the most expensive items?
What is the SQL query to find the most expensive items?
Signup and view all the answers
What is the SQL query to find items that contain 3 or more ingredients?
What is the SQL query to find items that contain 3 or more ingredients?
Signup and view all the answers
What is the SQL query to find the number of ingredients in a particular item?
What is the SQL query to find the number of ingredients in a particular item?
Signup and view all the answers
What is the SQL query to find all suppliers who referred two or more suppliers?
What is the SQL query to find all suppliers who referred two or more suppliers?
Signup and view all the answers
What is the SQL query to find the meals containing an ingredient from a specific food group?
What is the SQL query to find the meals containing an ingredient from a specific food group?
Signup and view all the answers
What is the SQL query to find all suppliers who did not recommend any other vendor?
What is the SQL query to find all suppliers who did not recommend any other vendor?
Signup and view all the answers
What is the SQL query to list the name and inventory value of each ingredient in two food groups?
What is the SQL query to list the name and inventory value of each ingredient in two food groups?
Signup and view all the answers
What is the SQL query to find all suppliers who provided more ingredients than a specific supplier?
What is the SQL query to find all suppliers who provided more ingredients than a specific supplier?
Signup and view all the answers
What is the SQL query to find the average inventory values for each supplier who recommends at least one different supplier?
What is the SQL query to find the average inventory values for each supplier who recommends at least one different supplier?
Signup and view all the answers
Study Notes
SQL Queries for Ingredient and Supplier Management
- Query ingredients supplied by a specific supplier using
supplierid
. - Retrieve names of ingredients supplied by two distinct suppliers with an
OR
condition. - Find supplier company names providing ingredients with fewer than 50 in inventory using a subquery.
- Calculate the average unit price of items for a selected supplier with
AVG(unitprice)
. - Identify suppliers referred by another supplier.
- Locate ingredients with inventories within 25% of the average inventory using a
BETWEEN
clause. - List companies referred by a supplier that provide ingredients in the 'milk' food group.
- Extract names and prices of items using ingredients supplied by a specific supplier.
- Find names and inventory values of ingredients exceeding the total inventory value provided by a particular supplier.
- Select ingredients supplied by any supplier except a specified supplier using the
!=
operator. - Identify small suppliers that do not provide ingredients with inventories greater than 100.
- Retrieve names and prices of items using ingredients from a certain supplier.
- Find items priced higher than any salads by using a subquery for
MAX(price)
on salad items. - Select names of ingredients supplied by two different suppliers using
NOT IN
. - Retrieve names of ingredients not supplied by two different suppliers.
- Find most expensive items in the inventory by using a
MAX(price)
condition. - List items with 3 or more ingredients using
HAVING COUNT(mw.ingredientid) >= 3
. - Count ingredients in a specified item through a
COUNT
aggregation. - Identify suppliers who referred two or more other suppliers along with their company names.
- Find meals containing ingredients from a specific food group, involving multiple joins across tables.
- Identify suppliers that have not recommended any other vendors using
NOT IN
. - List ingredient names and inventory values for two specified food groups through
IN
. - Retrieve suppliers that have provided more ingredients than a designated supplier using a subquery.
- Calculate average inventory values for suppliers recommending at least one other supplier.
Query Techniques
- Utilize
JOIN
statements to relate multiple tables. - Use nested
SELECT
statements for complex conditions. - Leverage aggregation functions like
AVG
,COUNT
, andMAX
for calculations. - Apply
WHERE
,HAVING
, andBETWEEN
for filtering data sets.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your understanding of SQL queries related to ingredient management and supplier information. This quiz covers fundamental SELECT statements and filtering techniques using WHERE and subqueries. Perfect for beginners looking to master SQL basics.