Академический Документы
Профессиональный Документы
Культура Документы
TABLE VALUES:
SQL> select * from movie;
M_TITLE M_LENGTH M_GENRES
OUTLINE
M_PCNAME
M_YOR
150 action
happy
surya_movies
1998
balu
120 love
abcdefg
a_productions
2000
evildead 90 horror
near to fear
abc_productions
2012
anakonda 60 horror
dare to see
b_productions
2012
surya_movies
2011
nippu
150 action
happy
90 comedy
danger
funny
6 rows selected.
SQL> select * from production;
PC_NAME
--------------surya_movies
abc_productions
a_productions
b_productions
PC_ADDRESS
--------------chennai
chennai
bangalore
bangalore
A_NAME
--------------naresh
nitin
A_DOB
--------01-JAN-80
01-JUL-86
surya_movies
1999
3 neha
4 nikitha
11-SEP-87
10-JAN-92
D_NAME
--------------shankar
svk
rm
D_DOB
--------01-JAN-80
13-MAR-83
27-JUL-86
OUTLINE
M_PCNAME
M_YOR
dare to see
b_productions
2012
2. QUERY>
select * from actors where a_id in(select ma_id from movieactors group by ma_ti
tle) in( select m_title from movie where (m_yor NOT BETWEEN 2000 and 2010)) grou
p by m_title having count(*)>1);
PENDING----------------------------------------------
SQL> select * from actors where a_id in(select ma_id from movieactors where ma_t
itle in(select m_title from movie where (m_yor < 2000 or m_yor > 2010) group by
m_title having count(m_title)>1));
no rows selected
SQL> select * from actors where a_id in(select ma_id from movieactors where ma_t
itle in(select m_title from movie where (m_yor not between 2000 and 2010) group
by m_title having count(m_title)>1));
no rows selected
3. QUERY
SQL> select * from production, (select m_pcname from movie group by m_pcname ord
er by count(m_pcname) desc) temp where temp.m_pcname = production.pc_name and r
ownum=1;
PC_NAME
PC_ADDRESS
M_PCNAME
--------------- --------------- --------------surya_movies
chennai
surya_movies
********************************************************************************
alternative query:
SQL> select* from(select m_pcname,count(m_pcname) as no_of_movies from movie gro
up by m_pcname order by no_of_movies desc) where rownum=1;
M_PCNAME
NO_OF_MOVIES
--------------- -----------surya_movies
2
*************************************************************
4.QUERY
SQL> select * from movie where m_title in (select md_title from moviedirectors w
here md_id in ( select d.d_id from directors d, actors a where a.a_dob=d.d_dob))
;
M_TITLE
M_LENGTH M_GENRES
OUTLINE
M_PCNAME
M_YOR
150 action
anakonda 60 horror
nippu
150 action
happy
dare to see
danger
surya_movies
b_productions
surya_movies
1998
2012
2011
5. QUERY :
SQL> select * from directors where d_id in(select md_id from moviedirectors wher
e md_title in (select m_title from movie where m_pcname='surya_movies'));
D_ID D_NAME
D_DOB
---------- --------------- --------11 shankar
01-JAN-80
SQL> select * from directors where d_id in(select md_id from moviedirectors wher
D_NAME
--------------shankar
svk
rm
D_DOB
--------01-JAN-80
13-MAR-83
27-JUL-86
*********************************************************************
SECOND QUERY =-==============================
SQL> select * from actors a, movie m, movieactors ma where a.a_id in(
select ma.ma_id from (
select ma.ma_title from movieactors group by ma.ma_title having count(ma.ma_titl
e) > 1));
and (movie.m_yor not between 2000 and 2010)));
select * from actors, movie m, movieactors ma where a.a_id in(select ma.ma_id f
rom (select ma.ma_title from movieactors group by ma.ma_title having count(ma.ma
_title > 1) and m.m_yor < '2000' or m.m_yor > '2010'