You are on page 1of 10

set sqlprompt prathees-->

prathees-->create table stu_details(stu_name varchar(20),co_name


varchar(20),du_month number(10),date_jion date,co_fee number(10),institute
varchar(20));

Table created.

prathees-->insert into stu_details


values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute');
Enter value for stu_name: tendulkar
Enter value for co_name: oracle
Enter value for du_month: 3
Enter value for date_jion: 12-nov-2010
Enter value for co_fee: 7500
Enter value for institute: ssi
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('tendulkar','oracle','3','12-nov-
2010','7500','ssi')

1 row created.

prathees-->/
Enter value for stu_name: kapli dev
Enter value for co_name: vb
Enter value for du_month: 2
Enter value for date_jion: 07-jan-2012
Enter value for co_fee: 3000
Enter value for institute: aptech
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('kapli dev','vb','2','07-jan-
2012','3000','aptech')

1 row created.

prathees-->/
Enter value for stu_name: ganguly
Enter value for co_name: assemply
Enter value for du_month: 5
Enter value for date_jion: 25-feb-2013
Enter value for co_fee: 10000
Enter value for institute: niit
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('ganguly','assemply','5','25-feb-
2013','10000','niit')

1 row created.

prathees-->/
Enter value for stu_name: dhoni
Enter value for co_name: java
Enter value for du_month: 6
Enter value for date_jion: 12-sep-2009
Enter value for co_fee: 5000
Enter value for institute: ssi
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('dhoni','java','6','12-sep-
2009','5000','ssi')

1 row created.

prathees-->/
Enter value for stu_name: dravid
Enter value for co_name: vc++
Enter value for du_month: 3
Enter value for date_jion: 07-mar-2013
Enter value for co_fee: 5000
Enter value for institute: aptech
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('dravid','vc++','3','07-mar-
2013','5000','aptech')

1 row created.

prathees-->/
Enter value for stu_name: agarkar
Enter value for co_name: foxpro
Enter value for du_month: 1
Enter value for date_jion: 15-apr-2012
Enter value for co_fee: 1000
Enter value for institute: niit
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('agarkar','foxpro','1','15-apr-
2012','1000','niit')

1 row created.

prathees-->/
Enter value for stu_name: srinath
Enter value for co_name: c
Enter value for du_month: 2
Enter value for date_jion: 12-jan2012
Enter value for co_fee: 300
Enter value for institute: vhnsnc
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('srinath','c','2','12-
jan2012','300','vhnsnc')

1 row created.

prathees-->/
Enter value for stu_name: kumble
Enter value for co_name: foxpro
Enter value for du_month: 2
Enter value for date_jion: 06-dec-2008
Enter value for co_fee: 700
Enter value for institute: ssi
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('kumble','foxpro','2','06-dec-
2008','700','ssi')
1 row created.

prathees-->/
Enter value for stu_name: kapli dev
Enter value for co_name: oracle
Enter value for du_month: 3
Enter value for date_jion: 01-nov-2007
Enter value for co_fee: 2500
Enter value for institute: vhnsnc
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('kapli dev','oracle','3','01-nov-
2007','2500','vhnsnc')

1 row created.

prathees-->/
Enter value for stu_name: gavaskar
Enter value for co_name: java
Enter value for du_month: 4
Enter value for date_jion: 01-jan-2011
Enter value for co_fee: 7000
Enter value for institute: vhnsnc
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('gavaskar','java','4','01-jan-
2011','7000','vhnsnc')

1 row created.

prathees-->/
Enter value for stu_name: kaif
Enter value for co_name: oracle
Enter value for du_month: 4
Enter value for date_jion: 01-aug-2012
Enter value for co_fee: 9500
Enter value for institute: ssi
old 1: insert into stu_details
values('&stu_name','&co_name','&du_month','&date_jion','&co_fee','&institute')
new 1: insert into stu_details values('kaif','oracle','4','01-aug-
2012','9500','ssi')

1 row created.

prathees-->select * from stu_details;

STU_NAME CO_NAME DU_MONTH DATE_JION CO_FEE INSTITUTE

-------------------- -------------------- --------- --------- ---------


--------------------
tendulkar oracle 3 12-NOV-10 7500 ssi

kapli dev vb 2 07-JAN-12 3000 aptech

ganguly assemply 5 25-FEB-13 10000 niit

dhoni java 6 12-SEP-09 5000 ssi

dravid vc++ 3 07-MAR-13 5000 aptech


agarkar foxpro 1 15-APR-12 1000 niit

srinath c 2 12-JAN-12 300 vhnsnc

kumble foxpro 2 06-DEC-08 700 ssi

kapli dev oracle 3 01-NOV-07 2500 vhnsnc

gavaskar java 4 01-JAN-11 7000 vhnsnc

kaif oracle 4 01-AUG-12 9500 ssi

11 rows selected.

prathees-->commit;

Commit complete.

prathees-->prathees-->select initcap(stu_name) from details;


select initcap(stu_name) from details
*
ERROR at line 1:
ORA-00942: table or view does not exist

prathees-->ed
Wrote file afiedt.buf

1* select initcap(stu_name) from stu_details


prathees-->/

INITCAP(STU_NAME)
--------------------
Tendulkar
Kapli Dev
Ganguly
Dhoni
Dravid
Agarkar
Srinath
Kumble
Kapli Dev
Gavaskar
Kaif

11 rows selected.

prathees-->select institute(co_fee) from stu_details group by institute;


select institute(co_fee) from stu_details group by institute
*
ERROR at line 1:
ORA-00904: "INSTITUTE": invalid identifier

prathees-->ed
Wrote file afiedt.buf
1* select institute,sum(co_fee) from stu_details group by institute
prathees-->/

INSTITUTE SUM(CO_FEE)
-------------------- -----------
aptech 8000
vhnsnc 9800
ssi 22700
niit 11000

prathees-->select date_jion "date of jioning",du_month "duration


month",add_month(date_jion,du_month) from stu_d
select date_jion "date of jioning",du_month "duration
month",add_month(date_jion,du_month) from stu_details
*
ERROR at line 1:
ORA-00904: "ADD_MONTH": invalid identifier

prathees-->ed
Wrote file afiedt.buf

1* select date_jion "date of jioning",du_month "duration


month",add_months(date_jion,du_month) from stu_detail
prathees-->/

date of j duration month ADD_MONTH


--------- -------------- ---------
12-NOV-10 3 12-FEB-11
07-JAN-12 2 07-MAR-12
25-FEB-13 5 25-JUL-13
12-SEP-09 6 12-MAR-10
07-MAR-13 3 07-JUN-13
15-APR-12 1 15-MAY-12
12-JAN-12 2 12-MAR-12
06-DEC-08 2 06-FEB-09
01-NOV-07 3 01-FEB-08
01-JAN-11 4 01-MAY-11
01-AUG-12 4 01-DEC-12

11 rows selected.

prathees-->select stu_name,sum(co_fee) from stu_details where stu_name='kapli dev'


group by stu_name;

STU_NAME SUM(CO_FEE)
-------------------- -----------
kapli dev 5500

prathees-->select max(co_fee) from stu_details;

MAX(CO_FEE)
-----------
10000

prathees-->ed
Wrote file afiedt.buf

1* select min(co_fee) from stu_details


prathees-->/

MIN(CO_FEE)
-----------
300

prathees-->select distinct(stu_name) from stu_details;

STU_NAME
--------------------
srinath
ganguly
agarkar
tendulkar
kapli dev
kumble
gavaskar
dhoni
kaif
dravid

10 rows selected.

prathees-->select institute,count(stu_name) from stu_details group by institute;

INSTITUTE COUNT(STU_NAME)
-------------------- ---------------
aptech 2
vhnsnc 3
ssi 4
niit 2

prathees-->select distinct(upper(dtu_name)) "course name" from stu_details;


select distinct(upper(dtu_name)) "course name" from stu_details
*
ERROR at line 1:
ORA-00904: "DTU_NAME": invalid identifier

prathees-->ed
Wrote file afiedt.buf

1* select distinct(upper(stu_name)) "course name" from stu_details


prathees-->/

course name
--------------------
KAPLI DEV
SRINATH
AGARKAR
KAIF
TENDULKAR
GANGULY
KUMBLE
GAVASKAR
DHONI
DRAVID

10 rows selected.
prathees-->select avg(co_fee) from stu_details;

AVG(CO_FEE)
-----------
4681.8182

prathees-->select to_char(date_jion,'ddth month yyyy') from stu_details;

TO_CHAR(DATE_JION,'
-------------------
12th november 2010
07th january 2012
25th february 2013
12th september 2009
07th march 2013
15th april 2012
12th january 2012
06th december 2008
01st november 2007
01st january 2011
01st august 2012

11 rows selected.

prathees-->select stu_name,date_jion from stu_details where date_jion=(select


max(date_jion) from stu_details;
select stu_name,date_jion from stu_details where date_jion=(select max(date_jion)
from stu_details
*
ERROR at line 1:
ORA-00921: unexpected end of SQL command

prathees-->ed
Wrote file afiedt.buf

1* select stu_name,date_jion from stu_details where date_jion=(select


max(date_jion) from stu_details);
prathees-->/
select stu_name,date_jion from stu_details where date_jion=(select max(date_jion)
from stu_details);

*
ERROR at line 1:
ORA-00911: invalid character

prathees-->ed
Wrote file afiedt.buf

1* select stu_name,date_jion from stu_details where date_jion=select


max(date_jion) from stu_details
prathees-->/
select stu_name,date_jion from stu_details where date_jion=select max(date_jion)
from stu_details
*
ERROR at line 1:
ORA-00936: missing expression
prathees-->ed
Wrote file afiedt.buf

1* select stu_name,date_jion from stu_details where date_jion=(select


max(date_jion) from stu_details)
prathees-->/

STU_NAME DATE_JION
-------------------- ---------
dravid 07-MAR-13

prathees-->select least(sysdate,date_jion) from stu_details;

LEAST(SYS
---------
12-NOV-10
07-JAN-12
25-FEB-13
12-SEP-09
07-MAR-13
15-APR-12
12-JAN-12
06-DEC-08
01-NOV-07
01-JAN-11
01-AUG-12

11 rows selected.

prathees-->select substr(institute,1,3) from stu_details;

SUB
---
ssi
apt
nii
ssi
apt
nii
vhn
ssi
vhn
vhn
ssi

11 rows selected.

prathees-->select substr(stu_name,1,3) from stu_details where institute='vhnsnc';

SUB
---
sri
kap
gav

prathees-->select stu_name from stu_details where extract(month from date_jion)=11;


STU_NAME
--------------------
tendulkar
kapli dev

prathees-->select stu_name from details where extract(year from date_jion)=2012;


select stu_name from details where extract(year from date_jion)=2012
*
ERROR at line 1:
ORA-00942: table or view does not exist

prathees-->ed
Wrote file afiedt.buf

1* select stu_name from stu_details where extract(year from date_jion)=2012


prathees-->/

STU_NAME
--------------------
kapli dev
agarkar
srinath
kaif

prathees-->select count(distinct(stu_name)) from stu_details where


institute='vhnsnc';

COUNT(DISTINCT(STU_NAME))
-------------------------
3

prathees-->select stu_name,length(stu_name) from stu_details;

STU_NAME LENGTH(STU_NAME)
-------------------- ----------------
tendulkar 9
kapli dev 9
ganguly 7
dhoni 5
dravid 6
agarkar 7
srinath 7
kumble 6
kapli dev 9
gavaskar 8
kaif 4

11 rows selected.

prathees-->select stu_name from details where du_month=3;


select stu_name from details where du_month=3
*
ERROR at line 1:
ORA-00942: table or view does not exist

prathees-->ed
Wrote file afiedt.buf
1* select stu_name from stu_details where du_month=3
prathees-->/

STU_NAME
--------------------
tendulkar
dravid
kapli dev

You might also like