cle database, if we have any date field such as DOB field in a ve can use DECODE function to sort the result based on our ORDER DK

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter3: Performing Calculations With Formulas And Functions
Section: Chapter Questions
Problem 3.15CP
icon
Related questions
Question
In Oracle database, if we have any date field such as DOB field in any of our table
then we can use DECODE function to sort the result based on our own customized
order.
This can be done by including the following in ORDER BY clause:
DECODE(TO_CHAR(DOB,'DAY'),
'SUNDAY', 1,
'MONDAY', 2,
'TUESDAY', 3,
True
False
'WEDNESDAY', 4,
'THURSDAY', 5,
'FRIDAY', 6,
'SATURDAY', 7)
This will generate the correct ordered result
Transcribed Image Text:In Oracle database, if we have any date field such as DOB field in any of our table then we can use DECODE function to sort the result based on our own customized order. This can be done by including the following in ORDER BY clause: DECODE(TO_CHAR(DOB,'DAY'), 'SUNDAY', 1, 'MONDAY', 2, 'TUESDAY', 3, True False 'WEDNESDAY', 4, 'THURSDAY', 5, 'FRIDAY', 6, 'SATURDAY', 7) This will generate the correct ordered result
BRANCH_NO SALES RANK
100
105
113
112
102
106
110
104
111
101
108
107
103
114
109
35007880
1
33658205 1
28680995
1
25414340
1
20175110
18802065
16087795
14439605 2
13796770 3
11957615
3
11520520 3
11467615
3
9939950
4
9036135 4
1646200 4
True
False
222 №
This can be done by including a RANK function:
DENSE_RANK() OVER (order by sum(subtotal) desc) Rank
Transcribed Image Text:BRANCH_NO SALES RANK 100 105 113 112 102 106 110 104 111 101 108 107 103 114 109 35007880 1 33658205 1 28680995 1 25414340 1 20175110 18802065 16087795 14439605 2 13796770 3 11957615 3 11520520 3 11467615 3 9939950 4 9036135 4 1646200 4 True False 222 № This can be done by including a RANK function: DENSE_RANK() OVER (order by sum(subtotal) desc) Rank
Expert 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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage