-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder Management System
More file actions
103 lines (64 loc) · 1.89 KB
/
Order Management System
File metadata and controls
103 lines (64 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Skip to main content
ALL
12
13
14
15
16
17
18
19
20
21
22
23
6. Order Management System
A retail company maintains the data of its customers in the CUSTOMER table. Write a query to print the IDs and the NAMEs of the customers, sorted by CUSTOMER.NAME in descending order. If two or more customers have the same CUSTOMER.NAME, then sort these by CUSTOMER.ID in ascending order.
Input Format
CUSTOMER
Name Type Description
ID Integer A customer ID in the inclusive range [1, 1000]. This is the primary key.
NAME String A customer name. This field contains between 1 and 100 characters (inclusive).
COUNTRY String The country of the customer.
CREDITS Integer The credit limit of the customer.
Output Format
The result should print the ids and the names of the customers, sorted by CUSTOMER.NAME in descending order. If two or more customers have the same CUSTOMER.NAME, then sort these by CUSTOMER.ID in ascending order.
CUSTOMER.ID CUSTOMER.NAME
Sample
CUSTOMER
ID NAME COUNTRY CREDITS
1 Frances White USA 200350
2 Carolyn Bradley UK 15354
3 Annie Fernandez France 359200
4 Ruth Hanson Albania 1060
5 Paula Fuller USA 14789
6 Bonnie Johnston China 100243
7 Ruth Gutierrez USA 998999
8 Ernest Thomas Canada 500500
9 Joe Garza UK 18782
10 Anne Harris USA 158367
Sample Output
4 Ruth Hanson
7 Ruth Gutierrez
5 Paula Fuller
9 Joe Garza
1 Frances White
8 Ernest Thomas
2 Carolyn Bradley
6 Bonnie Johnston
3 Annie Fernandez
10 Anne Harris
Explanation
According to the lexicographical arrangement,
Ruth Hanson > Ruth Gutierrez > Paula Fuller > Joe Garza > Frances White > Ernest Thomas > Carolyn Bradley > Bonnie Johnston > Annie Fernandez > Anne Harris
There are no duplicate names, so all records are in descending alphabetical NAME order.
Test Results
Run Query
Submit
/*
Enter your query here.
*/
//CODE
SELECT customer.ID, customer.name
FROM customer
ORDER BY customer.name, customer.id ASC;