2017-03-07 02:01:00 +01:00
|
|
|
-- http://www.sqlserver-dba.com/2011/09/this-is-a-followup-on-my-earlier-post-of-sql-server-test-data-generation-testing-tools-i-had-some-requests-for-my-set-up-pr.html
|
|
|
|
SELECT N_NAME, SUM(L_EXTENDEDPRICE*(1-L_DISCOUNT)) AS REVENUE
|
|
|
|
FROM CUSTOMER, ORDERS, LINEITEM, SUPPLIER, NATION, REGION
|
|
|
|
WHERE C_CUSTKEY = O_CUSTKEY AND L_ORDERKEY = O_ORDERKEY AND L_SUPPKEY = S_SUPPKEY
|
|
|
|
AND C_NATIONKEY = S_NATIONKEY AND S_NATIONKEY = N_NATIONKEY AND N_REGIONKEY = R_REGIONKEY
|
2017-07-21 02:47:45 +02:00
|
|
|
AND R_NAME = 'ASIA' AND O_ORDERDATE >= '1994-01-01'
|
2017-03-07 02:01:00 +01:00
|
|
|
AND O_ORDERDATE < DATEADD(YY, 1, cast('1994-01-01' as datetime))
|
|
|
|
GROUP BY N_NAME
|
|
|
|
ORDER BY REVENUE DESC
|