(jlive)[crashcourse]>SELECT vend_id, COUNT(*) AS num_prods FROM products GROUP BY vend_id WITH ROLLUP;
+---------+-----------+
| vend_id | num_prods |
+---------+-----------+
|
|
|
|
|
+---------+-----------+
5 rows in set (0.00 sec)
(jlive)[crashcourse]>SELECT vend_id, COUNT(*) AS num_prods FROM products GROUP BY vend_id HAVING COUNT(*) >= 2;
+---------+-----------+
| vend_id | num_prods |
+---------+-----------+
|
|
|
|
+---------+-----------+
4 rows in set (0.00 sec)
(jlive)[crashcourse]>SELECT vend_id, COUNT(*) AS num_prods FROM products WHERE prod_price >= 10 GROUP BY vend_id HAVING COUNT(*) >= 2;
+---------+-----------+
| vend_id | num_prods |
+---------+-----------+
|
|
+---------+-----------+
2 rows in set (0.00 sec)
(jlive)[crashcourse]>SELECT
order_num, SUM(quantity*item_price) ordertotal FROM orderitems GROUP BY order_num
HAVING
+-----------+------------+
| order_num | ordertotal |
+-----------+------------+
|
|
|
|
+-----------+------------+
4 rows in set (0.00 sec)
(jlive)[crashcourse]>SELECT order_num, SUM(quantity*item_price) AS ordertotal FROM orderitems GROUP BY order_num HAVING SUM(quantity*item_price) >= 50 ORDER BY ordertotal DESC LIMIT 2 OFFSET 1;
+-----------+------------+
| order_num | ordertotal |
+-----------+------------+
|
|
+-----------+------------+
2 rows in set (0.00 sec)