# Create a query that display the last name,hire date and the day of the week on which the employee started. Label the column DAY. Order the results by the day of the week starting with Monday.LAST_NAME HIRE_DATE DAYGrant 24-MAY-99 MONDAYErnst 21-MAY-99 TUESDAYMourgos 16-NOV-99 TUESDAY------- ----- SUNDAY

#### Deepali

• Sep 14th, 2006

try this query-

SELECT last_name, hire_date, TO_CHAR(hire_date,'DAY') AS DAY

FROM employees

ORDER BY hire_date, DAY;

#### zecar Profile Answers by zecar Questions by zecar

• Sep 14th, 2006

if we order by hire date it will give the dates in ascending order which is fine but if we order by day then it will give the days in ascending order like monday,friday,saturday,sunday,thurday.... (alphaebetically)it wont give monday,tueday,wednesday

#### Manikandan

• Sep 22nd, 2006

SELECT last_name, hire_date, TO_CHAR(hire_date,'DAY') AS DAYFROM employeesORDER BY DAY;

#### pallavimeher Profile Answers by pallavimeher

• Nov 16th, 2006

SELECT last_name , hire_date,to_char(hire_date,'DAY') DAY,to_char(hire_date,'D') FROM employees
ORDER BY to_char(hire_date-1,'d');

#### onlyforyou Profile Answers by onlyforyou Questions by onlyforyou

• May 15th, 2007

select ename,to_char(hiredate,'DD-Mon-YYYY') as hire_date,to_char(hiredate,'Day') as day

from emp

order by to_char(hiredate,'d')

#### amikat Profile Answers by amikat

• Jun 3rd, 2008

select last_name,hire_date, to_char(hire_date,'DAY') as DAY
from emp
order by to_char(hire_date-1,'d');

#### saginandkishore Profile Answers by saginandkishore Questions by saginandkishore

• Jun 19th, 2008

NANDU@NQP3>select dayofweek Day from test456;

DAY
--------------------
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

7 rows selected.

NANDU@NQP3>select dayofweek day, decode(dayofweek , 'Monday'    ,     1
2                                      , 'Tuesday'   ,     2
3                                      , 'Wednesday' ,     3
4                                      , 'Thursday'  ,     4
5                                      , 'Friday'    ,     5
6                                      , 'Saturday'  ,     6
7                                      , 'Sunday'    ,     7) DISCARD_STUFF
8  from test456 order by 2;

-------------------- -------------
Monday                           1
Tuesday                          2
Wednesday                        3
Thursday                         4
Friday                           5
Saturday                         6
Sunday                           7

7 rows selected.

NANDU@NQP3>

With Oracle there are 100's of ways of doing things :). Hope this is the way you wanted the output to be displayed.

in continuation, you can discard the discard_stuff and get the order wanted as shown below.

select dayofweek day
from test456
order by decode(dayofweek , 'Monday' , 1
, 'Tuesday' , 2
, 'Wednesday' , 3
, 'Thursday' , 4
, 'Friday' , 5
, 'Saturday' , 6
, 'Sunday' , 7)

--Sagi

--Sagi

#### imranbaig.geek Profile Answers by imranbaig.geek

• Dec 1st, 2009

select ename, TO_CHAR(hiredate-1,'d'), hiredate, TO_CHAR(hiredate, 'DAY') as "DAY" from emp order by TO_CHAR(hiredate-1,'d') asc

#### emraan Profile Answers by emraan

• Dec 28th, 2009

SELECT ename, hiredate, to_char(hiredate, 'DAY') FROM emp ORDER BY to_char(hiredate-1, 'd')

#### mjennna52 Profile Answers by mjennna52

• Aug 28th, 2010

eg. if use scott/tiger schema:

select ename, TO_CHAR(hiredate, 'DAY') as DAY from emp;

#### sankar babu Profile Answers by sankar babu

• May 25th, 2011

select last_name,hiredate,to_char(hiredate,'day') day

from emp

#### nitin

• Jun 20th, 2016

To display the name and hiredate who was hired in 1993

#### Abhishek Verma

• Jul 20th, 2016

#### sreeharibabu

• Sep 24th, 2016

```CodeSELECT ename, hiredate, TO_CHAR(hiredate,DAY) AS DAY ,TO_CHAR(hiredate-1,D)
FROM emp
ORDER BY  TO_CHAR(hiredate-1,D) ;```

ENAME HIREDATE DAY TO_CHAR(HIREDATE-1,D)
1 MARTIN 9/28/1981 MONDAY 1

#### shivam srivastava

• Sep 29th, 2016

```CodeSELECT name, hiredate FROM emp WHERE hiredate LIKE %1993;
OR
SELECT name, hiredate FROM emp WHERE hiredate LIKE %1993 ORDER BY hiredate;```

#### Shaheed

• Dec 14th, 2016

ORDER BY statement is worng, as we cant put alias in order by clause