[Schema (values) (types)]: | solvency_ii |  Addresses : address_id (text) , address_details (number) | Locations : location_id (text) , other_details (number) | Products : product_id (text) , product_type_code (number) , product_name (text) , product_price (number) | Parties : party_id (text) , party_details (number) | Assets : asset_id (text) , other_details (number) | Channels : channel_id (text) , other_details (number) | Finances : finance_id (text) , other_details (number) | Events : event_id (text) , address_id (number) , channel_id (text) , event_type_code (number) , finance_id (text) , location_id (number) | Products_in_Events : product_in_event_id (text) , event_id (number) , product_id (text) | Parties_in_Events : party_id (text) , event_id (number) , role_code (text) | Agreements : document_id (text) , event_id (number) | Assets_in_Events : asset_id (text) , event_id (number);
[Primary Keys]: addresses : address_id, locations : location_id, products : product_id, parties : party_id, assets : asset_id, channels : channel_id, finances : finance_id, events : event_id, products_in_events : product_in_event_id, parties_in_events : party_id, agreements : document_id, assets_in_events : asset_id
[Foreign Keys]: events : finance_id = finances : finance_id | events : address_id = addresses : address_id | events : location_id = locations : location_id | products_in_events : product_id = products : product_id | products_in_events : event_id = events : event_id | parties_in_events : event_id = events : event_id | parties_in_events : party_id = parties : party_id | agreements : event_id = events : event_id | assets_in_events : event_id = events : event_id | assets_in_events : event_id = events : event_id

Question: How many products are there?
SQL: SELECT count(*) FROM Products

Question: List the name of products in ascending order of price.
SQL: SELECT Product_Name FROM Products ORDER BY Product_Price ASC

Question: What are the names and type codes of products?
SQL: SELECT Product_Name ,  Product_Type_Code FROM Products

Question: Show the prices of the products named "Dining" or "Trading Policy".
SQL: SELECT Product_Price FROM Products WHERE Product_Name  =  "Dining" OR Product_Name  =  "Trading Policy"

Question: What is the average price for products?
SQL: SELECT avg(Product_Price) FROM Products

Question: What is the name of the product with the highest price?
SQL: SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1

Question: Show different type codes of products and the number of products with each type code.
SQL: SELECT Product_Type_Code ,  COUNT(*) FROM Products GROUP BY Product_Type_Code

Question: Show the most common type code across products.
SQL: SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC LIMIT 1

Question: Show the product type codes that have at least two products.
SQL: SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*)  >=  2

Question: Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000.
SQL: SELECT Product_Type_Code FROM Products WHERE Product_Price  >  4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price  <  3000

Question: Show the names of products and the number of events they are in.
SQL: SELECT T1.Product_Name ,  COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name

Question: Show the names of products and the number of events they are in, sorted by the number of events in descending order.
SQL: SELECT T1.Product_Name ,  COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name ORDER BY COUNT(*) DESC

Question: Show the names of products that are in at least two events.
SQL: SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*)  >=  2

Question: Show the names of products that are in at least two events in ascending alphabetical order of product name.
SQL: SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*)  >=  2 ORDER BY T1.Product_Name

Question: List the names of products that are not in any event.
SQL: SELECT Product_Name FROM Products WHERE Product_ID NOT IN (SELECT Product_ID FROM Products_in_Events)