# 9.1.1dbGetQuery(mydb,"SELECT AVG(prod_price) AS avg_priceFROM Products;")
avg_price
1 6.823333
dbGetQuery(mydb,"SELECT AVG(prod_price) AS avg_priceFROM ProductsWHERE vend_id = 'DLL01';")
avg_price
1 3.865
# 9.1.2dbGetQuery(mydb,"SELECT COUNT(*) AS num_custFROM Customers;")
num_cust
1 6
dbGetQuery(mydb,"SELECT COUNT(cust_email) AS num_custFROM Customers;")
num_cust
1 4
# 9.1.3dbGetQuery(mydb,"SELECT MAX(prod_price) AS max_priceFROM Products;")
max_price
1 11.99
# 9.1.4dbGetQuery(mydb,"SELECT MIN(prod_price) AS min_priceFROM Products;")
min_price
1 3.49
# 9.1.5dbGetQuery(mydb,"SELECT SUM(quantity) AS items_orderedFROM OrderItemsWHERE order_num = 20005;")
items_ordered
1 200
dbGetQuery(mydb,"SELECT SUM(item_price*quantity) AS total_priceFROM OrderItemsWHERE order_num = 20005;")
total_price
1 1648
# 9.2dbGetQuery(mydb,"SELECT AVG(DISTINCT prod_price) AS avg_priceFROM ProductsWHERE vend_id = 'DLL01';")
avg_price
1 4.24
# 9.3dbGetQuery(mydb,"SELECT COUNT(*) AS num_items,MIN(prod_price) AS price_min,MAX(prod_price) AS price_max,AVG(prod_price) AS price_avgFROM Products;")
Warning: Missing values are always removed in SQL aggregation functions.
Use `na.rm = TRUE` to silence this warning
This warning is displayed once every 8 hours.