CustomerID | Cust_Name | City | Grade | SalesMan_ID |
---|
3002 | Nick Rimando | New York | 100 | 5001 |
3007 | Brad Davis | New York | 200 | 5001 |
3005 | Graham Zusi | California | 200 | 5002 |
3008 | Julian Green | London | 300 | 5002 |
3004 | Fabian Johnson | Paris | 300 | 5006 |
3009 | Geoff Cameron | Berlin | 100 | 5003 |
3003 | Jozy Altidor | Moscow | 200 | 5007 |
3001 | Brad Guzan | London | | 5005 |
فهرست تعداد Grade هایی که بزرگتر از میانگین عددهایی که مقادیر فیلد City آنها برابر New York است
SELECT Grade,Count(*) From Customer Group By Grade Having Grade>(Select AVG(Grade) From Customer Where City="New York")
Select {0} From {1} Where {2} Group By {3} Having {4}
City | Avg(Grade) |
---|
Berlin | 100 |
California | 200 |
London | 150 |
Moscow | 200 |
New York | 150 |
Paris | 300 |
City | Grade | TotGr |
---|
New York | 100 | 100 |
New York | 200 | 300 |
California | 200 | 200 |
London | 300 | 300 |
Paris | 300 | 300 |
Berlin | 100 | 100 |
Moscow | 200 | 200 |
London | | 0 |
City | max(TotGr) | count | Avg |
---|
Berlin | 100 | 1 | 100 |
California | 200 | 1 | 200 |
London | 300 | 2 | 150 |
Moscow | 200 | 1 | 200 |
New York | 300 | 2 | 150 |
Paris | 300 | 1 | 300 |
جدول employee
id | name | salary | role |
---|
1 | Augustine Hammond | 10000 | Developer |
2 | Perice Mundford | 10000 | Manager |
3 | Cassy Delafoy | 30000 | Developer |
4 | Garwood Saffen | 40000 | Manager |
5 | Faydra Beaves | 50000 | Developer |
جدول awards
id | employee_id | award_date |
---|
1 | 1 | 2022-04-01 |
2 | 3 | 2022-05-01 |
SELECT id, name FROM employee WHERE id IN (SELECT employee_id FROM awards);
id | name |
---|
1 | Augustine Hammond |
3 | Cassy Delafoy |
SELECT * FROM employee WHERE role = 'Developer' AND salary > ( SELECT salary FROM employee WHERE role = 'Manager' )
id | name | salary | role |
---|
3 | Cassy Delafoy | 30000 | Developer |
5 | Faydra Beaves | 50000 | Developer |
OrderID | OriginalVale |
---|
1 | 1 |
2 | 3 |
7 | 2 |
8 | 1 |
9 | 7 |
11 | 3 |
12 | 1 |
OrderID | OriginalVale | Sum |
---|
1 | 1 | 1 |
2 | 3 | 4 |
7 | 2 | 6 |
8 | 1 | 7 |
9 | 7 | 14 |
11 | 3 | 17 |
12 | 1 | 18 |