QL query using Rank() Retrieve the top-selling product of each day. Use the total sold quantity to determine the top-selling product. The top-selling product has the highest total sold quantity. If there is a tie, the solution must pick up the tie. Include the order date, product id, and the total sold quantity of the top-selling product of each day in the returned data. Sort the returned data by the order date.*/

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

SQL query using Rank()

Retrieve the top-selling product of each day.
Use the total sold quantity to determine the top-selling product.
The top-selling product has the highest total sold quantity.
If there is a tie, the solution must pick up the tie.
Include the order date, product id, and the total sold
quantity of the top-selling product of each day in the returned data.
Sort the returned data by the order date.*/

ESelect*
from Sales. SalesOrderHeader;
Eselect*
from Sales. SalesOrderDetail:
Lab 3-5
133 %
画结果 消息
SalesOrderID RevisionNumber
OrderDate
DueDate
ShipDate
Status OnlineOr der Flag SalesOrder Number
Pur chaseOr der Number
AccountNumber
CustomerID SalesPersonID TerritoryID BillToAddressI) A
1
43659
3
2005-07-01 00:00:00.000
2005-07-13 00:00:00.000
2005-07-08 00:00:00. 000
S043659
PO522145787
10-4020-000676 29825
279
985
2
43660
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000
S043660
PO18850127500
10-4020-000117 29672
279
5
921
3
43661
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000
2005-07-08 00:00:00.000
S043661
PO18473189620
10-4020-000442 29734
282
517
4
43662
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00.000
S043662
PO18444174044
10-4020-000227
29994
282
482
5
43663
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000
5
S043663
PO18009186470
10-4020-000510 29565
276
4
1073
6
43664
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000
5.
S043664
PO16617121983
10-4020-000397 29898
280
1
876
7
43665
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000
2005-07-08 00:00:00. 000
S043665
PO16588191572
10-4020-000146
29580
283
1
849
8
43666
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000
S043666
PO16008173883
10-4020-000511 30052
276
4
1074
9
43667
3
2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000
S043667
PO15428132599
10-4020-000646 29974
277
3
629
10
43668
3
2005-07-01 00:00:00.000 2005-07-13 00:00:00.000
2005-07-08 00:00:00. 000
S043668
P014732180295
10-4020-000514
29614
282
529
11
43669
3
2005-07-01 00:00:00. 000
2005-07-13 00:00:00.000
2005-07-08 00:00:00.000
5
S043669
PO14123169936
10-4020-000578
29747
283
1
895
-- -----
---
>
SalesOrderID
SalesOrderDetailID CarrierTrackingNumber OrderQty ProductID Special0fferID Uni tPrice
Uni tPriceDiscount LineTotal
rowguid
Modi fiedDate
1
43659
1
4911-403C-98
1
776
1
2024. 994
0.00
2024. 994000 B207C96D-D9E6-402B-8470-2CC176C42283
2005-07-01 00:00:00. 000
2
43659
2
4911-403C-98
3
777
1
2024. 994
0.00
6074. 982000
7ABB600D-1E77-41BE-9FE5-B9142CFC08FA
2005-07-01 00:00:00. 000
3
43659
3
4911-403C-98
1
778
1
2024. 994
0.00
2024. 994000
475CF8C6-49F6-486E-BOAD-AFC6A50CDD2F
2005-07-01 00:00:00. 000
4
43659
4
4911-403C-98
1
771
1
2039. 994
0.00
2039. 994000
04C4DE91-5815-45D6-8670-F462719FBCE3
2005-07-01 00:00:00. 000
5
43659
4911-403C-98
1
772
1
2039. 994
0.00
2039. 994000
5A74C7D2-E641-438E-A7AC-37BF23280301
2005-07-01 00:00:00. 000
6
43659
4911-403C-98
2
773
1
2039. 994
0.00
4079. 988000
CE472532-A4C0-45BA-816E-EEFD3FD848B3
2005-07-01 00:00:00. 000
7
43659
7
4911-403C-98
1
774
1
2039, 994
0.00
2039. 994000 80667840-F962-4EE3-96E0-AECA108EOD4F
2005-07-01 00:00:00.000
8
43659
8.
4911-403C-98
3
714
1
28. 8404
0.00
86.521200
E9D54907-E7B7-4969-8009-76BA69F8A836
2005-07-01 00:00:00. 000
43659
9
4911-403C-98
1
716
1
28. 8404
0.00
28. 840400
AA542630-BDCD-4CE5-89A0-CIBF82747725
2005-07-01 00:00:00. 000
10
43659
10
4911-403C-98
709
1
5. 70
0.00
34. 200000
AC769034-3C2F-495C-A5A7-3B71CDB25D4E
2005-07-01 00:00:00. 000
11
43659
11
4911-403C-98
2
712
1
5. 1865
0.00
10. 373000
06A66921-689F-4199-A912-DDAFD383472B
2005-07-01 00:00:00. 000
Transcribed Image Text:ESelect* from Sales. SalesOrderHeader; Eselect* from Sales. SalesOrderDetail: Lab 3-5 133 % 画结果 消息 SalesOrderID RevisionNumber OrderDate DueDate ShipDate Status OnlineOr der Flag SalesOrder Number Pur chaseOr der Number AccountNumber CustomerID SalesPersonID TerritoryID BillToAddressI) A 1 43659 3 2005-07-01 00:00:00.000 2005-07-13 00:00:00.000 2005-07-08 00:00:00. 000 S043659 PO522145787 10-4020-000676 29825 279 985 2 43660 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000 S043660 PO18850127500 10-4020-000117 29672 279 5 921 3 43661 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00.000 S043661 PO18473189620 10-4020-000442 29734 282 517 4 43662 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00.000 S043662 PO18444174044 10-4020-000227 29994 282 482 5 43663 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000 5 S043663 PO18009186470 10-4020-000510 29565 276 4 1073 6 43664 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000 5. S043664 PO16617121983 10-4020-000397 29898 280 1 876 7 43665 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000 S043665 PO16588191572 10-4020-000146 29580 283 1 849 8 43666 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000 S043666 PO16008173883 10-4020-000511 30052 276 4 1074 9 43667 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00. 000 2005-07-08 00:00:00. 000 S043667 PO15428132599 10-4020-000646 29974 277 3 629 10 43668 3 2005-07-01 00:00:00.000 2005-07-13 00:00:00.000 2005-07-08 00:00:00. 000 S043668 P014732180295 10-4020-000514 29614 282 529 11 43669 3 2005-07-01 00:00:00. 000 2005-07-13 00:00:00.000 2005-07-08 00:00:00.000 5 S043669 PO14123169936 10-4020-000578 29747 283 1 895 -- ----- --- > SalesOrderID SalesOrderDetailID CarrierTrackingNumber OrderQty ProductID Special0fferID Uni tPrice Uni tPriceDiscount LineTotal rowguid Modi fiedDate 1 43659 1 4911-403C-98 1 776 1 2024. 994 0.00 2024. 994000 B207C96D-D9E6-402B-8470-2CC176C42283 2005-07-01 00:00:00. 000 2 43659 2 4911-403C-98 3 777 1 2024. 994 0.00 6074. 982000 7ABB600D-1E77-41BE-9FE5-B9142CFC08FA 2005-07-01 00:00:00. 000 3 43659 3 4911-403C-98 1 778 1 2024. 994 0.00 2024. 994000 475CF8C6-49F6-486E-BOAD-AFC6A50CDD2F 2005-07-01 00:00:00. 000 4 43659 4 4911-403C-98 1 771 1 2039. 994 0.00 2039. 994000 04C4DE91-5815-45D6-8670-F462719FBCE3 2005-07-01 00:00:00. 000 5 43659 4911-403C-98 1 772 1 2039. 994 0.00 2039. 994000 5A74C7D2-E641-438E-A7AC-37BF23280301 2005-07-01 00:00:00. 000 6 43659 4911-403C-98 2 773 1 2039. 994 0.00 4079. 988000 CE472532-A4C0-45BA-816E-EEFD3FD848B3 2005-07-01 00:00:00. 000 7 43659 7 4911-403C-98 1 774 1 2039, 994 0.00 2039. 994000 80667840-F962-4EE3-96E0-AECA108EOD4F 2005-07-01 00:00:00.000 8 43659 8. 4911-403C-98 3 714 1 28. 8404 0.00 86.521200 E9D54907-E7B7-4969-8009-76BA69F8A836 2005-07-01 00:00:00. 000 43659 9 4911-403C-98 1 716 1 28. 8404 0.00 28. 840400 AA542630-BDCD-4CE5-89A0-CIBF82747725 2005-07-01 00:00:00. 000 10 43659 10 4911-403C-98 709 1 5. 70 0.00 34. 200000 AC769034-3C2F-495C-A5A7-3B71CDB25D4E 2005-07-01 00:00:00. 000 11 43659 11 4911-403C-98 2 712 1 5. 1865 0.00 10. 373000 06A66921-689F-4199-A912-DDAFD383472B 2005-07-01 00:00:00. 000
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
SQL Query
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education