Use the tables given in the SQL Query Practice #1
Express the following queries in SQL:
SELECT AVG(salary) FROM employee where title = 'Stock Clerk';
SELECT title, AVG(salary) FROM employee GROUP BY title HAVING title <> 'president' AND title<>'vice president' ORDER BY title;
SELECT manager_id, AVG(salary) FROM employee GROUP BY manager_id HAVING AVG(salary) > 1000;
SELECT date_ordered, AVG(total) FROM orders GROUP BY date_ordered HAVING count(date_ordered) > 1 AND AVG(total) > 1000 ORDER BY AVG(total) DESC;
SELECT customer.customer_name, count(*) FROM orders JOIN customer on customer.customer_id = orders.customer_id GROUP BY customer.customer_name;
SELECT employee_first_name, avg(salary) FROM employee GROUP BY employee_first_name HAVING avg(salary) > 1000;
SELECT round(months_between(TO_DATE('2002-03-28','YYYY-MM-DD'),TO_DATE('2000-06-24','YYYY-MM-DD'))) AS mnth, round(months_between(TO_Date('2002-03-28','YYYY-MM__DD'),TO_DATE('2000-06-24','YYYY-MM-DD'))*30) as day FROM dual;
SELECT add_months(sysdate,2) FROM dual;
SELECT start_date "start date" , last_day(start_date) "Last Day" FROM employee;
SELECT round(months_between(date_shipped,date_ordered)*30) AS day FROM orders WHERE extract(month FROM date_ordered)=6;