Saturday, January 2, 2016

SQL -- Aggregate Functions (Group by, MIN, MAX)


From the items_ordered table, select the item, maximum price, and minimum price for each specific item in the table. 







SELECT item, MAX(price), MIN(price)

FROM items_ordered

GROUP BY item;

Friday, November 27, 2015

SQL -- Aggregate Functions (Group By)


How many people are in each unique state in the customers table? Select the state and display the number of people in each. 



SELECT state, count(state)
FROM customers
GROUP BY state;
 

 

SQL -- Aggregate Functions (MIN)


For all of the tents that were ordered in the items_ordered table, what is the price of the lowest tent? Hint: Your query should return the price only.


SELECT MIN(price)
FROM items_ordered
WHERE item = 'Tent';