systemappsprogram.blogspot.com

SQL Basic Commands

\\SQL Oracle******

WITH  dept_costs AS (SELECT department_name, SUM(salary) dept_total FROM employees e, departments d WHERE e.department_id = d.department_idGROUP BY department_name), avg_cost AS (SELECT SUM(dept_total)/COUNT(*) avg FROM dept_costs)SELECT * FROM dept_costs WHERE dept_total > (SELECT avg FROM avg_cost) ORDER BY department_name;SELECT *FROM employees WHERE department_id = 30 ORDER BY last_name;SELECT last_name, job_id, salary, department_id FROM employees WHERE NOT (job_id = 'PU_CLERK' AND department_id = 30) ORDER BY last_name;SELECT a.department_id "Department", a.num_emp/b.total_count "%_Employees",a.sal_sum/b.total_sal "%_Salary" FROM (SELECT department_id, COUNT(*) num_emp, SUM(salary) sal_sum FROM employees GROUP BY department_id) a, (SELECT COUNT(*) total_count, SUM(salary) total_sal FROM employees) b ORDER BY a.department_id;SELECT * FROM sales PARTITION (sales_q2_2000) s WHERE s.amount_sold > 1500 ORDER BY cust_id, time_id, channel_id;SELECT * FROM orders WHERE order_date < TO_DATE('2000-06-15', 'YYYY-MM-DD');SELECT COUNT(*) * 10 FROM orders SAMPLE (10); COUNT(*)*10SELECT salary FROM employees WHERE last_name = 'Langa'; SALARY ---------- 3800 UPDATE employees SET salary = 4000 WHERE last_name = 'Langa'; 1 row updated. SELECT salary FROM employees WHERE last_name = 'Langa';SELECT salary FROM employees AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' MINUTE) WHERE last_name = 'Langa';SELECT salary FROM employees VERSIONS BETWEEN TIMESTAMP SYSTIMESTAMP - INTERVAL '10' MINUTE AND SYSTIMESTAMP - INTERVAL '1' MINUTE WHERE last_name = 'Langa';

UPDATE employees SET salary =
 (SELECT salary FROM employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '2' MINUTE)
WHERE last_name = 'Langa')
 WHERE last_name = 'Langa';
1 row updated.
SELECT salary
FROM employees
WHERE last_name = 'Langa';
Share:

Translate

Popular Posts

Recent Posts

Support System Software

Customer support is usually one of the key aspects for all companies, both small and large enterprises. Having a reliable customer support system will result in a positive image of your brand and will be a clear sing that you actually care about your clients and put effort into keeping them satisfied. Our team of SaaS experts have collected and tested all popular customer support software services currently available in the market. Our list should allow you to more easily decide which solution will work best for your business. Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.