Skip to content

Instantly share code, notes, and snippets.

@sqlparser
Created December 12, 2023 04:50
Show Gist options
  • Save sqlparser/a71c969d20dfbd4615a3ccc976a36c94 to your computer and use it in GitHub Desktop.
Save sqlparser/a71c969d20dfbd4615a3ccc976a36c94 to your computer and use it in GitHub Desktop.
Oracle sample SQL
```sql
CREATE VIEW vsal
AS
SELECT a.deptno "Department",
a.num_emp / b.total_count "Employees",
a.sal_sum / b.total_sal "Salary"
FROM (SELECT deptno,
Count() num_emp,
SUM(sal) sal_sum
FROM scott.emp
WHERE city = 'NYC'
GROUP BY deptno) a,
(SELECT Count() total_count,
SUM(sal) total_sal
FROM scott.emp
WHERE city = 'NYC') b
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment