help me with this, i need to sort the order to be like sun,mon,tue,wed,thu,fri,sat
6 8394
You need to give more details than that to get help.
i have to write a query in such a way i have to get no of employees joined on a particular day.
i have written the following query
select count(*)"no of emp joined",to_char(hiredate,'day') "day" from emp group by to_char(hiredate,'day');
output:
no of emp joined day
2 friday
1 monday
2 saturday
2 sunday
3 thursday
3 tuesday
1 wednesday
but i want the days to be sorted in order starting from sun,mon,tue,wed,thu,fri,sat
For any arbitrary order sorting, check out amit's post in this thread.
the hard and long way; -
select
-
count(*) as NO_EMP_JOINED,
-
to_char(hiredate,'day') AS DAY_OF_WEEK,
-
(case when DAY_OF_WEEK = 'Sunday' then 1
-
when DAY_OF_WEEK = 'Monday' then 2
-
when DAY_OF_WEEK = 'Tuesday' then 3
-
when DAY_OF_WEEK = 'Wednesday' then 4
-
when DAY_OF_WEEK = 'Thursday' then 5
-
when DAY_OF_WEEK = 'Friday' then 6
-
when DAY_OF_WEEK = 'Saturday' then 7
-
else 99
-
end) AS ORDERCOLUMN
-
from emp
-
group by to_char(hiredate,'day')
-
order by ORDERCOLUMN
-
and the easy way, Oracle saw you coming; http://www.techonthenet.com/oracle/f...ns/to_char.php
check right at the bottom of the page and the question.
-
select
-
count(*) as NO_EMP_JOINED,
-
to_char(hiredate,'day') AS DAY_OF_WEEK
-
from emp
-
group by to_char(hiredate,'day')
-
order by decode(upper(substr(DAY_OF_WEEK, 1,2)), 'SU', 0, 'MO', 1, 'TU', 2,'WE', 3,'TH', 4,'FR', 5,'SA', 6, 99)
-
based on http://bytes.com/forum/thread823124.html
Thanx for ur help it works
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: One's Too Many |
last post by:
Ran into a strange problem today:
8.1.7 on AIX 4.3.3
Database and applications had been working fine for two years and all
of a sudden a couple of regularly-run queries are now no longer...
|
by: Steve Wells |
last post by:
Hi,
We need an Oracle expert to help us convert a SQL appication to Oracle
for a particuler project we're working on. We have all the stored
procs., etc. already converted, we're just having...
|
by: Matt Liverance |
last post by:
I REALLY dont want to switch to oracle :( but I cant get these tables
working any faster.
I've got 2 dedicated servers, each with a slave, all run 32gig 15k rpm
raid 5 on u320 perc raid...
|
by: Xah Lee |
last post by:
Sort a List
Xah Lee, 200510
In this page, we show how to sort a list in Python & Perl and also
discuss some math of sort.
To sort a list in Python, use the “sort” method. For example:
...
|
by: James P. |
last post by:
Hello,
I have a report with the Priority field is used as sort order and
grouping. The problem is the data in this Priority field if sorted in
ascending order is: High, Low, and Medium. How...
| |
by: thebison |
last post by:
Hi all,
I hope someone can help with this relatively simple problem.
I am building a timesheet application using ASP.NET C# with Visual
Studio 2003.As it is only a protoype application, my...
|
by: tbramley |
last post by:
Hi,
I've got a cross tab query which is sorted by area then month but the month is sorted in alphabetical order and I was wondering if this can be done in Month order e.g. April, May, June, July...
|
by: Prosdo |
last post by:
Hi guys. I have a final program for school and the assignment is to show the top 5 numbers for the Cash 5 lottery over the past few days. I think I have all my loops right.I think I have the output...
|
by: chevyas123 |
last post by:
How do i write a function to calculate business days excluding weekends and holidays in oracle?
Actually i need to prepare a calendar for my monthly activities i.e activity x to be performed on 3rd...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |