select round('16-may-07','mon') from dual;
select round(to_date('16-may-07'),'yy')) from dual;
select round(to_date('16-may-07'),'yy')
from dual;
ROUND(TO_
---------
01-JAN-07
select round(to_date('16-jun-07'),'yy')
from dual;
select round(to_date('16-jul-07'),'yy')
from dual;
select round(to_date('15-jul-07'),'mon')
from dual;
select trunc(to_date('16-jul-09'),'yy')
from dual;
SQL> select sysdate ,
to_char(sysdate,'dd month year') from dual;
SYSDATE TO_CHAR(SYSDATE,'DDMONTHYEAR')
--------- -------------------------------------------------------
29-OCT-09 29 october two thousand nine
select sysdate ,
to_char(sysdate,'day') from dual;
SQL> select sysdate ,
2 to_char(sysdate,'day') from dual;
SYSDATE TO
--------- --
29-OCT-09 44
select to_char(to_date('05-may-05'),'Q') from dual;
select to_char(sysdate,'dd-mon-yy HH24:MI:SS ')
from dual;
T
-
2
select to_char(sysdate,'dd-mon-yy HH:MI:SS AM')
from dual;
TO_CHAR(SYSDATE,'DD-M
---------------------
29-oct-09 03:01:44 PM
select to_char(sysdate,'dd-mon-yy HH24:MI:SS ')
from dual;
TO_CHAR(SYSDATE,'DD
-------------------
29-oct-09 15:02:20
select lname,salary ,commission_pct ,coalesce(commission_pct,salary,dailywages) income from edetails;
FNAME LNAME SALARY INCOME
--------------- -------------------- ---------- ----------
sai kiran 23000 23000
jai krishnan 27000 27000
ashok kumar 27000 .1
Geethu Mohan 27000 .3
Arafat Aboobacker 27000 .2
Seetha Raman 24000 .2
Urmilla Unni 28000 .2
Sajesh Kumar 29000 .2
Rajesh C 25000 .2
Manu Jayan 29000 .2
Santhosh Jayan 22000 .2
FNAME LNAME SALARY INCOME
--------------- -------------------- ---------- ----------
hari prasad 500
12 rows selected.
select lname,salary ,commission_pct ,dailywages,
coalesce(commission_pct,salary,dailywages) income from
edetails;
LNAME SALARY COMMISSION_PCT INCOME
-------------------- ---------- -------------- ----------
kiran 23000 23000
krishnan 27000 27000
kumar 27000 .1 .1
Mohan 27000 .3 .3
Aboobacker 27000 .2 .2
Raman 24000 .2 .2
Unni 28000 .2 .2
Kumar 29000 .2 .2
C 25000 .2 .2
Jayan 29000 .2 .2
Jayan 22000 .2 .2
LNAME SALARY COMMISSION_PCT INCOME
-------------------- ---------- -------------- ----------
prasad 500
12 rows selected.
SQL> select lname,salary ,commission_pct ,dailywages,
2 coalesce(commission_pct,salary,dailywages) income from
3 edetails;
LNAME SALARY COMMISSION_PCT DAILYWAGES INCOME
-------------------- ---------- -------------- ---------- ----------
kiran 23000 23000
krishnan 27000 27000
kumar 27000 .1 .1
Mohan 27000 .3 .3
Aboobacker 27000 .2 .2
Raman 24000 .2 .2
Unni 28000 .2 .2
Kumar 29000 .2 .2
C 25000 .2 .2
Jayan 29000 .2 .2
Jayan 22000 .2 .2
LNAME SALARY COMMISSION_PCT DAILYWAGES INCOME
-------------------- ---------- -------------- ---------- ----------
prasad 500 500
12 rows selected.
select deptid,salary from edetails;
DEPT SALARY
---- ----------
D01 23000
D01 27000
D02 27000
D02 27000
D03 27000
D01 24000
D01 28000
D02 29000
D02 25000
D03 29000
D03 22000
select deptid,sum(salary) "departwise total" from edetails group by deptid;
select deptid,sum(salary) "departwise total" from edetails
group by deptid;
DEPT departwise total
---- ----------------
D01 102000
D03 78000
D02 108000
select deptid,sum(salary) "departwise total" from edetails
group by deptid
having sum(salary) > 100000;
SQL> select rownum,eid, fname from edetails;
ROWNUM EID FNAME
---------- ---- ---------------
1 e1 sai
2 e2 jai
3 e3 ashok
4 e4 Geethu
5 e5 Arafat
6 e6 Seetha
7 e7 Urmilla
8 e9 Sajesh
9 e8 Rajesh
10 e10 Manu
11 e11 Santhosh
ROWNUM EID FNAME
---------- ---- ---------------
12 e12 hari
12 rows selected.
SQL> select * from edetails where rownum < 8;
EID FNAME LNAME HIREDATE SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAG
---- --------------- -------------------- --------- ---------- -------- ---- -------------- --------
e1 sai kiran 23-FEB-09 23000 IT_PROG D01
e2 jai krishnan 24-APR-09 27000 ST_CLERK D01
e3 ashok kumar 21-APR-09 27000 SAEXE D02 .1
e4 Geethu Mohan 14-APR-09 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 21-APR-09 27000 SA_REP D03 .2
e6 Seetha Raman 21-APR-09 24000 SA_REP D01 .2
e7 Urmilla Unni 21-APR-09 28000 SA_REP D01 .2
select rowid,rownum,eid,fname from edetails;
ROWID ROWNUM EID FNAME
------------------ ---------- ---- ---------------
AAAM5RAABAAAPCaAAA 1 e1 sai
AAAM5RAABAAAPCaAAB 2 e2 jai
AAAM5RAABAAAPCaAAC 3 e3 ashok
AAAM5RAABAAAPCaAAD 4 e4 Geethu
AAAM5RAABAAAPCaAAE 5 e5 Arafat
AAAM5RAABAAAPCaAAF 6 e6 Seetha
AAAM5RAABAAAPCaAAG 7 e7 Urmilla
AAAM5RAABAAAPCaAAH 8 e9 Sajesh
AAAM5RAABAAAPCaAAI 9 e8 Rajesh
AAAM5RAABAAAPCaAAJ 10 e10 Manu
AAAM5RAABAAAPCaAAK 11 e11 Santhosh
ROWID ROWNUM EID FNAME
------------------ ---------- ---- ---------------
AAAM5RAABAAAPCaAAL 12 e12 hari
select sysdate , sysdate +4,sysdate -10 from dual;
SYSDATE SYSDATE+4 SYSDATE-1
--------- --------- ---------
29-OCT-09 02-NOV-09 19-OCT-09
select round(to_date('16-may-07'),'yy')) from dual;
select round(to_date('16-may-07'),'yy')
from dual;
ROUND(TO_
---------
01-JAN-07
select round(to_date('16-jun-07'),'yy')
from dual;
select round(to_date('16-jul-07'),'yy')
from dual;
select round(to_date('15-jul-07'),'mon')
from dual;
select trunc(to_date('16-jul-09'),'yy')
from dual;
SQL> select sysdate ,
to_char(sysdate,'dd month year') from dual;
SYSDATE TO_CHAR(SYSDATE,'DDMONTHYEAR')
--------- -------------------------------------------------------
29-OCT-09 29 october two thousand nine
select sysdate ,
to_char(sysdate,'day') from dual;
SQL> select sysdate ,
2 to_char(sysdate,'day') from dual;
SYSDATE TO
--------- --
29-OCT-09 44
select to_char(to_date('05-may-05'),'Q') from dual;
select to_char(sysdate,'dd-mon-yy HH24:MI:SS ')
from dual;
T
-
2
select to_char(sysdate,'dd-mon-yy HH:MI:SS AM')
from dual;
TO_CHAR(SYSDATE,'DD-M
---------------------
29-oct-09 03:01:44 PM
select to_char(sysdate,'dd-mon-yy HH24:MI:SS ')
from dual;
TO_CHAR(SYSDATE,'DD
-------------------
29-oct-09 15:02:20
select lname,salary ,commission_pct ,coalesce(commission_pct,salary,dailywages) income from edetails;
FNAME LNAME SALARY INCOME
--------------- -------------------- ---------- ----------
sai kiran 23000 23000
jai krishnan 27000 27000
ashok kumar 27000 .1
Geethu Mohan 27000 .3
Arafat Aboobacker 27000 .2
Seetha Raman 24000 .2
Urmilla Unni 28000 .2
Sajesh Kumar 29000 .2
Rajesh C 25000 .2
Manu Jayan 29000 .2
Santhosh Jayan 22000 .2
FNAME LNAME SALARY INCOME
--------------- -------------------- ---------- ----------
hari prasad 500
12 rows selected.
select lname,salary ,commission_pct ,dailywages,
coalesce(commission_pct,salary,dailywages) income from
edetails;
LNAME SALARY COMMISSION_PCT INCOME
-------------------- ---------- -------------- ----------
kiran 23000 23000
krishnan 27000 27000
kumar 27000 .1 .1
Mohan 27000 .3 .3
Aboobacker 27000 .2 .2
Raman 24000 .2 .2
Unni 28000 .2 .2
Kumar 29000 .2 .2
C 25000 .2 .2
Jayan 29000 .2 .2
Jayan 22000 .2 .2
LNAME SALARY COMMISSION_PCT INCOME
-------------------- ---------- -------------- ----------
prasad 500
12 rows selected.
SQL> select lname,salary ,commission_pct ,dailywages,
2 coalesce(commission_pct,salary,dailywages) income from
3 edetails;
LNAME SALARY COMMISSION_PCT DAILYWAGES INCOME
-------------------- ---------- -------------- ---------- ----------
kiran 23000 23000
krishnan 27000 27000
kumar 27000 .1 .1
Mohan 27000 .3 .3
Aboobacker 27000 .2 .2
Raman 24000 .2 .2
Unni 28000 .2 .2
Kumar 29000 .2 .2
C 25000 .2 .2
Jayan 29000 .2 .2
Jayan 22000 .2 .2
LNAME SALARY COMMISSION_PCT DAILYWAGES INCOME
-------------------- ---------- -------------- ---------- ----------
prasad 500 500
12 rows selected.
select deptid,salary from edetails;
DEPT SALARY
---- ----------
D01 23000
D01 27000
D02 27000
D02 27000
D03 27000
D01 24000
D01 28000
D02 29000
D02 25000
D03 29000
D03 22000
select deptid,sum(salary) "departwise total" from edetails group by deptid;
select deptid,sum(salary) "departwise total" from edetails
group by deptid;
DEPT departwise total
---- ----------------
D01 102000
D03 78000
D02 108000
select deptid,sum(salary) "departwise total" from edetails
group by deptid
having sum(salary) > 100000;
SQL> select rownum,eid, fname from edetails;
ROWNUM EID FNAME
---------- ---- ---------------
1 e1 sai
2 e2 jai
3 e3 ashok
4 e4 Geethu
5 e5 Arafat
6 e6 Seetha
7 e7 Urmilla
8 e9 Sajesh
9 e8 Rajesh
10 e10 Manu
11 e11 Santhosh
ROWNUM EID FNAME
---------- ---- ---------------
12 e12 hari
12 rows selected.
SQL> select * from edetails where rownum < 8;
EID FNAME LNAME HIREDATE SALARY JOB_ID DEPT COMMISSION_PCT DAILYWAG
---- --------------- -------------------- --------- ---------- -------- ---- -------------- --------
e1 sai kiran 23-FEB-09 23000 IT_PROG D01
e2 jai krishnan 24-APR-09 27000 ST_CLERK D01
e3 ashok kumar 21-APR-09 27000 SAEXE D02 .1
e4 Geethu Mohan 14-APR-09 27000 SA_MAN D02 .3
e5 Arafat Aboobacker 21-APR-09 27000 SA_REP D03 .2
e6 Seetha Raman 21-APR-09 24000 SA_REP D01 .2
e7 Urmilla Unni 21-APR-09 28000 SA_REP D01 .2
select rowid,rownum,eid,fname from edetails;
ROWID ROWNUM EID FNAME
------------------ ---------- ---- ---------------
AAAM5RAABAAAPCaAAA 1 e1 sai
AAAM5RAABAAAPCaAAB 2 e2 jai
AAAM5RAABAAAPCaAAC 3 e3 ashok
AAAM5RAABAAAPCaAAD 4 e4 Geethu
AAAM5RAABAAAPCaAAE 5 e5 Arafat
AAAM5RAABAAAPCaAAF 6 e6 Seetha
AAAM5RAABAAAPCaAAG 7 e7 Urmilla
AAAM5RAABAAAPCaAAH 8 e9 Sajesh
AAAM5RAABAAAPCaAAI 9 e8 Rajesh
AAAM5RAABAAAPCaAAJ 10 e10 Manu
AAAM5RAABAAAPCaAAK 11 e11 Santhosh
ROWID ROWNUM EID FNAME
------------------ ---------- ---- ---------------
AAAM5RAABAAAPCaAAL 12 e12 hari
select sysdate , sysdate +4,sysdate -10 from dual;
SYSDATE SYSDATE+4 SYSDATE-1
--------- --------- ---------
29-OCT-09 02-NOV-09 19-OCT-09
No comments:
Post a Comment
Thanks for your valuable comments