Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SQL HELP! (Photos of the database attached) Question 1. Genrate the SQL commands

ID: 3826681 • Letter: S

Question

SQL HELP!

(Photos of the database attached)

Question 1. Genrate the SQL commands to create the following output:

c_name

c_custkey 1

O_ORDERDATE

O_ORDERKEY

O_TOTALPRICE

Customer#000000001

1

1/29/1997

24322

231040.44

Customer#000000001

1

10/29/1995

53283

165928.33

Customer#000000001

1

11/18/1997

14656

28599.83

Customer#000000001

1

3/29/1998

34019

89230.03

Customer#000000001

1

3/4/1997

36422

270087.44

Customer#000000001

1

5/8/1994

52263

51134.82

Customer#000000001

1

6/23/1997

9154

357345.46

Customer#000000001

1

6/5/1993

31653

152411.41

Customer#000000001

1

8/13/1993

43879

83095.85

Customer#000000002

2

12/29/1994

44962

45657.87

Customer#000000002

2

2/19/1993

6980

170842.93

Customer#000000002

2

3/13/1996

38276

201568.55

Customer#000000002

2

3/4/1996

20257

181875.60

Customer#000000002

2

5/18/1998

16129

50178.44

Customer#000000002

2

5/24/1997

28167

37156.97

Customer#000000002

2

5/3/1993

29408

154867.09

The table is sorted/order based on ascending custmer key/name. Limit to 10 records.

2. Modify your query and produce the following results.

Customer#000000001

1

1428873.61

9

Customer#000000002

2

1156504.92

10

Customer#000000004

4

4134567.39

31

Customer#000000005

5

1084042.74

9

Customer#000000007

7

3922020.98

24

Column 1 is the customer Name, Columne 2, is the customer key, column 3 is the total of the customer orders ($$) and column 4 is the number of orders.

c_name

c_custkey 1

O_ORDERDATE

O_ORDERKEY

O_TOTALPRICE

Customer#000000001

1

1/29/1997

24322

231040.44

Customer#000000001

1

10/29/1995

53283

165928.33

Customer#000000001

1

11/18/1997

14656

28599.83

Customer#000000001

1

3/29/1998

34019

89230.03

Customer#000000001

1

3/4/1997

36422

270087.44

Customer#000000001

1

5/8/1994

52263

51134.82

Customer#000000001

1

6/23/1997

9154

357345.46

Customer#000000001

1

6/5/1993

31653

152411.41

Customer#000000001

1

8/13/1993

43879

83095.85

Customer#000000002

2

12/29/1994

44962

45657.87

Customer#000000002

2

2/19/1993

6980

170842.93

Customer#000000002

2

3/13/1996

38276

201568.55

Customer#000000002

2

3/4/1996

20257

181875.60

Customer#000000002

2

5/18/1998

16129

50178.44

Customer#000000002

2

5/24/1997

28167

37156.97

Customer#000000002

2

5/3/1993

29408

154867.09

My Admin phpl Recent Favorites nformsion schema rogion r structure E SOL Search H insert Eport Impot operations Tracking Current select ique colu Grid edit, checkb Edit, Copy and Delete feat lable. Showing rows 0.24 (1500 otal. Querytook 0.0010 acconda) c oustiey: Number rows Fiber rows Search this table Options c nationkey Phone c attbal miktseg 2 Customer 000000002 XST NCWDvaWNe6tEgewfmAchLXak 13 23-768-687-3665 121.66 AUTOMOBILE 3 Customert000000003 MGgkdTD2WBHm AUTOMOBILE 4 14-128-19X-5944 2888 B3 MACHINERY 3 13-750 942-6354 7E4.47 HOUSEHOLD 20 30 114 gea 4951 7E38.57 AUTOMOBILE 8 28-190-B82-8759 9661.85 AUTOMOBILE 8 Customer 000000008 loBlobaDAymmc, oPrRYBCPlyGU8xoBPmith15 B-338 906.3875 8324.07 FUAN 0 Customer 000000010 6LuEaveKABPLVogl2ArL Q3rqzuzcT1 v2 6 15-T41-346 BBT0 2763.64 HOUSEHOLD Customer!00000001 3439 272 0 BULONG 2 Customer 00000001 13 23-791-276-1263 3098,49 HOUSEHOLD 3 Customurt0000000 313 751-547 5074 3857.34 BUILDING 14. CustomAR00000001 23 33-687-642-7601 2788.52 HOUSEHOLD Customart0000000 10 20781.609 3107 MEB 1.03 FURNITURE 2 12-970-882-3487 634 AUTOMOBILE 8 Customerh0000000 20 Customer 000000000 JPK8PoplMNs 22 32-957-234-0742 03.40 FURNITURE 21 Customurt0000000e 428.25 MACHINERY 3 13-808-545-9701 5A1.9B MACHINERY 23 Customer 0000000ea Ody W13NTBe30CaMpgifmcYsaown6TKT 3 13312-MT2 B245 3332.02 HOUSEHOLD 9255 B7 MACHINERY 22-303-468-3533 7133.70 FURNI l Number otrowe 25 Fiber rows Search this table a Profiling guar regular platelets according furiously special deposits aoMe slyly. furiously special packages waka. slyly reg slyly final accounts sublele carefully syly iron blitholy fin nstructions haggloistoathy sauto. special deposits wake along ironic foxes. Shyl. theodolites kindle carefully carefully regular dep. ironic deposits quickly after tho gits regul deposits afixsutlly blithely final ideas are bold, final trays aloop careful pocialidoas.c... furiously express packages regular courts pla. depoaia are accounta: tuffy even dependencies ironic dopondoncios acoording to tho slyly regular pinto beans boost uftly bold dolphins dotect quickly abouttho sp deposas nod blithely unusual packages nod quickly quickly ionic deposits furiouety oven traye among tho fluffily furious taxes after the stealthy deposits. regular dependencies serve bithely stealthy dugou. palplats sloop uly unusual instructo breve deposits amongthe deposits sleep unusual, rogular packagos walko, styly unusual cour. final requests wake furiously bl regular, ironic request Explain SOL Create PHP Code

Explanation / Answer

1. select top 10 c_name,c_custkey,O_ORDERDATE,O_ORDERKEY,O_TOTALPRICE from customer c, orders o where c.c_custkey=o.o_custkey order by c_custkey;

This query retrieves top 10 records of the required fields as a table order by custkey .


2. select c_name,c_custkey,sum(O_TOTALPRICE),count(O_ORDERKEY) from customer,orders where c_custkey=o_custkey group by c_custkey;

This query retrieves the required fileds as a table.