SlideShare une entreprise Scribd logo
1  sur  9
SCHEMAS:

SQL> create table studies (pname varchar(30),splace varchar(20), course varchar(20), ccost number);

Table created.

SQL> create table software(pname varchar(20),title varchar(20),devin varchar(40),scost number,dcost
number,sold number);

Table created.

SQL> create table programmer(pname varchar(20),dob date,doj date,sex char(7),prof1 varchar(30),prof2
varchar(20),sal number);

Table created.

SQL> insert into studies values('neha','pentafour','DCA',3000);

1 row created.

SQL> insert into studies values('mick','perryridge','PGDCA',10000);

1 row created.

SQL> insert into studies values('john','downtown','DCA',4000);

1 row created.

SQL> select * from studies;

PNAME                         SPLACE                 COURSE
------------------------------ -------------------- --------------------
    CCOST
----------
neha                      pentafour            DCA
     3000

mick                      perryridge           PGDCA
  10000

john                     downtown               DCA
   4000


SQL> insert into studies values('sam','pragathi','PGDCA',15000);

1 row created.

SQL> select * from studies;

PNAME                         SPLACE                COURSE
------------------------------ -------------------- --------------------
    CCOST
----------
neha                      pentafour            DCA
     3000

mick                      perryridge           PGDCA
  10000

john                     downtown               DCA
   4000


PNAME                         SPLACE                 COURSE
------------------------------ -------------------- --------------------
    CCOST
----------
sam                       pragathi            PGDCA
    15000



SQL> insert all into software values('raj','Gtalk','oracle',7000,5000,150) into software
values('kumar','chrome','vb',6000,4000,120) select * from dual;

2 rows created.



SQL> insert all into software values('mani','db2','oracle',7000,5000,150) into software
values('rakesh','inventory','vb',10000,9000,200) select * from dual;

2 rows created.

SQL> select * from software;

PNAME                  TITLE
-------------------- --------------------
DEVIN                                   SCOST DCOST                   SOLD
---------------------------------------- ---------- ---------- ----------
raj              Gtalk
oracle                                7000        5000        150

kumar              chrome
vb                                   6000       4000        120

mani              db2
oracle                                7000       5000        150


PNAME                 TITLE
-------------------- --------------------
DEVIN                                   SCOST DCOST                   SOLD
---------------------------------------- ---------- ---------- ----------
rakesh             inventory
vb                                  10000        9000        200


SQL> insert all into programmer values('sri',to_date('8-apr-1981','dd-mon-yyyy'),to_date('13-feb-
1998','dd-mon-yyyy'),'male','c','c++',25000) into programmer values('ferdy',to_date('11-mar-1979','dd-
mon-yyyy'),to_date('4-jun-1990'),'male','c++','pascal',45000) select * from dual;

2 rows created.

SQL> insert all into programmer values('shalini',to_date('30-apr-1981','dd-mon-yyyy'),to_date('28-aug-
1998','dd-mon-yyyy'),'female','c','c++',30000) into programmer values('harini',to_date('11-may-1982','dd-
mon-yyyy'),to_date('19-sep-1999'),'female','java','java',40000) select * from dual;

2 rows created.

SQL> select * from programmer;

PNAME                  DOB         DOJ        SEX PROF1
-------------------- --------- --------- ------- ------------------------------
PROF2                      SAL
-------------------- ----------
sri              08-APR-81 13-FEB-98 male c
c++                   25000

ferdy             11-MAR-79 04-JUN-90 male c++
pascal               45000

shalini           30-APR-81 28-AUG-98 female c
c++                 30000


PNAME                  DOB         DOJ        SEX PROF1
-------------------- --------- --------- ------- ------------------------------
PROF2                      SAL
-------------------- ----------
harini            11-MAY-82 19-SEP-99 female java
java                  40000
QUERIES:

1.SQL> select avg(scost)from software where devin='oracle';

AVG(SCOST)
----------
     7000


2.SQL> select
pname,trunc(months_between(sysdate,dob)/12)"age",trunc(months_between(sysdate,doj)/12)"experience
"from programmer;

PNAME                       age experience
-------------------- ---------- ----------
sri                    31        15
ferdy                    34        22
shalini                  31        14
harini                   30        13


3.SQL> select pname from studies where course='PGDCA';

PNAME
------------------------------
mick
sam


4.SQL> select max(sold) from software;

 MAX(SOLD)
----------
     200


5.SQL> select pname,dob from programmer where to_char(dob,’mon’)=’apr’;

PNAME
----------------
Sri
shalini



6.SQL> select min(ccost) from studies;

MIN(CCOST)
----------
     3000
7.SQL> select count(*) from studies where course='DCA';

  COUNT(*)
----------
       2


8.SQL> select sum(scost*sold-dcost) from software where devin='vb';

SUM(SCOST*SOLD-DCOST)
---------------------
           2707000


9.SQL> select * from software where pname='rakesh';

PNAME                  TITLE
-------------------- --------------------
DEVIN                                   SCOST DCOST                   SOLD
---------------------------------------- ---------- ---------- ----------
rakesh             inventory
vb                                  10000        9000        200



10.SQL> select count(*) from studies where splace='pentafour';

  COUNT(*)
----------
       1


11.SQL> select * from software where scost*sold-dcost>5000;

PNAME                  TITLE
-------------------- --------------------
DEVIN                                   SCOST DCOST                   SOLD
---------------------------------------- ---------- ---------- ----------
raj              Gtalk
oracle                                7000        5000        150

kumar              chrome
vb                                   6000     4000       120

mani              db2
oracle                                7000     5000        150


PNAME                  TITLE
-------------------- --------------------
DEVIN                                   SCOST DCOST                   SOLD
---------------------------------------- ---------- ---------- ----------
rakesh             inventory
vb                                  10000        9000        200



12.SQL> select ceil(dcost/scost) from software;

CEIL(DCOST/SCOST)
-----------------
            1
            1
            1
            1


13.SQL> select *from software where scost*sold>=dcost;

PNAME                  TITLE
-------------------- --------------------
DEVIN                                   SCOST DCOST                   SOLD
---------------------------------------- ---------- ---------- ----------
raj              Gtalk
oracle                                7000        5000        150

kumar             chrome
vb                                 6000       4000       120

mani              db2
oracle                              7000       5000        150


PNAME                  TITLE
-------------------- --------------------
DEVIN                                   SCOST DCOST                   SOLD
---------------------------------------- ---------- ---------- ----------
rakesh             inventory
vb                                  10000        9000        200




14.SQL> select max(scost) from software where devin='vb';


MAX(SCOST)
----------
    10000
15.SQL> select avg(scost) from software where devin='oracle';

AVG(SCOST)
----------
     7000



16.SQL> select count(*) from studies where splace='pragathi';

  COUNT(*)
----------
       1


17.SQL> select count(*) from studies where ccost between 9000 and 16000;


  COUNT(*)
----------
       2


18.SQL> select avg(ccost) from studies;

AVG(CCOST)
----------
     8000


19.SQL> select pname from programmer where prof1='c'or prof2='c';

PNAME
--------------------
sri
shalini


20.SQL> select count(pname) from programmer where prof1 in('c','pascal')or prof2 in('c','pascal');

COUNT(PNAME)
------------
        3


21.SQL> select count(pname) from programmer where prof1 not in('c','c++')or prof2 not in('c','c++');

COUNT(PNAME)
------------
        2
22.SQL> select round(max(months_between(sysdate,dob)/12)) from programmer where sex='male';

ROUND(MAX(MONTHS_BETWEEN(SYSDATE,DOB)/12))
------------------------------------------
                              34



23.SQL> select round(avg(months_between(sysdate,dob)/12)) from programmer where sex='female';

ROUND(AVG(MONTHS_BETWEEN(SYSDATE,DOB)/12))
------------------------------------------
                              31


24.SQL> select pname,trunc(months_between(sysdate,doj)/12) from programmer order by pname desc;

PNAME                  TRUNC(MONTHS_BETWEEN(SYSDATE,DOJ)/12)
-------------------- -------------------------------------
sri                                        15
shalini                                      14
harini                                       13
ferdy                                        22



25.SQL> select pname from programmer where to_char(dob,'mon')=to_char(sysdate,'mon');


PNAME
--------------------
ferdy



26.SQL> select count(*) from programmer where sex='female';

  COUNT(*)
----------
       2


27.SQL> select distinct(prof1) from programmer where sex='male';

PROF1
------------------------------
c
c++
28.SQL> select avg(sal) from programmer;

  AVG(SAL)
----------
    35000



29.SQL> select count(*) from programmer where sal between 20000 and 40000;

  COUNT(*)
----------
       3


30.SQL> select * from programmer where prof1 not in('c','c++','pascal') and prof2 not in('c','c++','pascal');

PNAME                  DOB         DOJ        SEX PROF1
-------------------- --------- --------- ------- ------------------------------
PROF2                      SAL
-------------------- ----------
harini            11-MAY-82 19-SEP-99 female java
java                  40000



31.SQL> select pname,title,scost from software where scost in(select max(scost) from software);

PNAME                  TITLE                   SCOST
-------------------- -------------------- ----------
rakesh             inventory                10000



32.SQL> select 'Mr.'|| pname||'-has' || trunc(months_between(sysdate,doj)/12) || 'yeares of
experience'"programmer" from programmer where sex='male';

programmer
--------------------------------------------------------------------------------
Mr.sri-has15yeares of experience
Mr.ferdy-has22yeares of experience


SQL> spool off

Contenu connexe

Tendances

Oracle12c For Developers
Oracle12c For DevelopersOracle12c For Developers
Oracle12c For DevelopersAlex Nuijten
 
Performance tuning a quick intoduction
Performance tuning   a quick intoductionPerformance tuning   a quick intoduction
Performance tuning a quick intoductionRiyaj Shamsudeen
 
Xen server 6.0 xe command reference (1.1)
Xen server 6.0 xe command reference (1.1)Xen server 6.0 xe command reference (1.1)
Xen server 6.0 xe command reference (1.1)Timote Lima
 
Exadata - Smart Scan Testing
Exadata - Smart Scan TestingExadata - Smart Scan Testing
Exadata - Smart Scan TestingMonowar Mukul
 
A close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesA close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesRiyaj Shamsudeen
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsConnor McDonald
 
SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013Connor McDonald
 
Demystifying cost based optimization
Demystifying cost based optimizationDemystifying cost based optimization
Demystifying cost based optimizationRiyaj Shamsudeen
 
Debunking myths about_redo_ppt
Debunking myths about_redo_pptDebunking myths about_redo_ppt
Debunking myths about_redo_pptRiyaj Shamsudeen
 
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習Computational Materials Science Initiative
 
Deep review of LMS process
Deep review of LMS processDeep review of LMS process
Deep review of LMS processRiyaj Shamsudeen
 
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلMohamed Moustafa
 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developersInSync Conference
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald PartitioningInSync Conference
 
Finding SQL execution outliers
Finding SQL execution outliersFinding SQL execution outliers
Finding SQL execution outliersMaxym Kharchenko
 

Tendances (20)

Oracle12c For Developers
Oracle12c For DevelopersOracle12c For Developers
Oracle12c For Developers
 
Performance tuning a quick intoduction
Performance tuning   a quick intoductionPerformance tuning   a quick intoduction
Performance tuning a quick intoduction
 
Xen server 6.0 xe command reference (1.1)
Xen server 6.0 xe command reference (1.1)Xen server 6.0 xe command reference (1.1)
Xen server 6.0 xe command reference (1.1)
 
Exadata - Smart Scan Testing
Exadata - Smart Scan TestingExadata - Smart Scan Testing
Exadata - Smart Scan Testing
 
A close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issuesA close encounter_with_real_world_and_odd_perf_issues
A close encounter_with_real_world_and_odd_perf_issues
 
Mysql56 replication
Mysql56 replicationMysql56 replication
Mysql56 replication
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
 
Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1Oracle 11g caracteristicas poco documentadas 3 en 1
Oracle 11g caracteristicas poco documentadas 3 en 1
 
SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013
 
Demystifying cost based optimization
Demystifying cost based optimizationDemystifying cost based optimization
Demystifying cost based optimization
 
Debunking myths about_redo_ppt
Debunking myths about_redo_pptDebunking myths about_redo_ppt
Debunking myths about_redo_ppt
 
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
 
Px execution in rac
Px execution in racPx execution in rac
Px execution in rac
 
Deep review of LMS process
Deep review of LMS processDeep review of LMS process
Deep review of LMS process
 
Analytic SQL Sep 2013
Analytic SQL Sep 2013Analytic SQL Sep 2013
Analytic SQL Sep 2013
 
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
 
Connor McDonald 11g for developers
Connor McDonald 11g for developersConnor McDonald 11g for developers
Connor McDonald 11g for developers
 
SAV
SAVSAV
SAV
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald Partitioning
 
Finding SQL execution outliers
Finding SQL execution outliersFinding SQL execution outliers
Finding SQL execution outliers
 

Similaire à Sql2

[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스PgDay.Seoul
 
Install and upgrade Oracle grid infrastructure 12.1.0.2
Install and upgrade Oracle grid infrastructure 12.1.0.2Install and upgrade Oracle grid infrastructure 12.1.0.2
Install and upgrade Oracle grid infrastructure 12.1.0.2Biju Thomas
 
12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQL12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQLConnor McDonald
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application DevelopmentSaurabh K. Gupta
 
OpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersOpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersConnor McDonald
 
Understanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersUnderstanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersEnkitec
 
Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationAndrew Hutchings
 
Ramco C Question Paper 2003
Ramco  C  Question  Paper 2003Ramco  C  Question  Paper 2003
Ramco C Question Paper 2003ncct
 
New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...Sage Computing Services
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatFranck Pachot
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所Hiroshi Sekiguchi
 
Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1Keshav Murthy
 
Sybase to oracle_conversion
Sybase to oracle_conversionSybase to oracle_conversion
Sybase to oracle_conversionSam Varadarajan
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceKaren Morton
 
Redo logfile addition in oracle rac 12c
Redo logfile addition in oracle rac 12cRedo logfile addition in oracle rac 12c
Redo logfile addition in oracle rac 12cDebasish Nayak
 

Similaire à Sql2 (20)

Sql queries
Sql queriesSql queries
Sql queries
 
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
[Pgday.Seoul 2019] Citus를 이용한 분산 데이터베이스
 
Install and upgrade Oracle grid infrastructure 12.1.0.2
Install and upgrade Oracle grid infrastructure 12.1.0.2Install and upgrade Oracle grid infrastructure 12.1.0.2
Install and upgrade Oracle grid infrastructure 12.1.0.2
 
12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQL12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQL
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application Development
 
OpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersOpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer Disasters
 
Understanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersUnderstanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-Developers
 
Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free Migration
 
Ramco C Question Paper 2003
Ramco  C  Question  Paper 2003Ramco  C  Question  Paper 2003
Ramco C Question Paper 2003
 
New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...
 
MySQL SQL Tutorial
MySQL SQL TutorialMySQL SQL Tutorial
MySQL SQL Tutorial
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor format
 
SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所SQLチューニング総合診療Oracle CloudWorld出張所
SQLチューニング総合診療Oracle CloudWorld出張所
 
Awr doag
Awr doagAwr doag
Awr doag
 
Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1Informix Warehouse Accelerator (IWA) features in version 12.1
Informix Warehouse Accelerator (IWA) features in version 12.1
 
Sybase to oracle_conversion
Sybase to oracle_conversionSybase to oracle_conversion
Sybase to oracle_conversion
 
ZFINDALLZPROGAM
ZFINDALLZPROGAMZFINDALLZPROGAM
ZFINDALLZPROGAM
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query Performance
 
Redo logfile addition in oracle rac 12c
Redo logfile addition in oracle rac 12cRedo logfile addition in oracle rac 12c
Redo logfile addition in oracle rac 12c
 
neutron测试例子
neutron测试例子neutron测试例子
neutron测试例子
 

Dernier

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Sql2

  • 1. SCHEMAS: SQL> create table studies (pname varchar(30),splace varchar(20), course varchar(20), ccost number); Table created. SQL> create table software(pname varchar(20),title varchar(20),devin varchar(40),scost number,dcost number,sold number); Table created. SQL> create table programmer(pname varchar(20),dob date,doj date,sex char(7),prof1 varchar(30),prof2 varchar(20),sal number); Table created. SQL> insert into studies values('neha','pentafour','DCA',3000); 1 row created. SQL> insert into studies values('mick','perryridge','PGDCA',10000); 1 row created. SQL> insert into studies values('john','downtown','DCA',4000); 1 row created. SQL> select * from studies; PNAME SPLACE COURSE ------------------------------ -------------------- -------------------- CCOST ---------- neha pentafour DCA 3000 mick perryridge PGDCA 10000 john downtown DCA 4000 SQL> insert into studies values('sam','pragathi','PGDCA',15000); 1 row created. SQL> select * from studies; PNAME SPLACE COURSE
  • 2. ------------------------------ -------------------- -------------------- CCOST ---------- neha pentafour DCA 3000 mick perryridge PGDCA 10000 john downtown DCA 4000 PNAME SPLACE COURSE ------------------------------ -------------------- -------------------- CCOST ---------- sam pragathi PGDCA 15000 SQL> insert all into software values('raj','Gtalk','oracle',7000,5000,150) into software values('kumar','chrome','vb',6000,4000,120) select * from dual; 2 rows created. SQL> insert all into software values('mani','db2','oracle',7000,5000,150) into software values('rakesh','inventory','vb',10000,9000,200) select * from dual; 2 rows created. SQL> select * from software; PNAME TITLE -------------------- -------------------- DEVIN SCOST DCOST SOLD ---------------------------------------- ---------- ---------- ---------- raj Gtalk oracle 7000 5000 150 kumar chrome vb 6000 4000 120 mani db2 oracle 7000 5000 150 PNAME TITLE
  • 3. -------------------- -------------------- DEVIN SCOST DCOST SOLD ---------------------------------------- ---------- ---------- ---------- rakesh inventory vb 10000 9000 200 SQL> insert all into programmer values('sri',to_date('8-apr-1981','dd-mon-yyyy'),to_date('13-feb- 1998','dd-mon-yyyy'),'male','c','c++',25000) into programmer values('ferdy',to_date('11-mar-1979','dd- mon-yyyy'),to_date('4-jun-1990'),'male','c++','pascal',45000) select * from dual; 2 rows created. SQL> insert all into programmer values('shalini',to_date('30-apr-1981','dd-mon-yyyy'),to_date('28-aug- 1998','dd-mon-yyyy'),'female','c','c++',30000) into programmer values('harini',to_date('11-may-1982','dd- mon-yyyy'),to_date('19-sep-1999'),'female','java','java',40000) select * from dual; 2 rows created. SQL> select * from programmer; PNAME DOB DOJ SEX PROF1 -------------------- --------- --------- ------- ------------------------------ PROF2 SAL -------------------- ---------- sri 08-APR-81 13-FEB-98 male c c++ 25000 ferdy 11-MAR-79 04-JUN-90 male c++ pascal 45000 shalini 30-APR-81 28-AUG-98 female c c++ 30000 PNAME DOB DOJ SEX PROF1 -------------------- --------- --------- ------- ------------------------------ PROF2 SAL -------------------- ---------- harini 11-MAY-82 19-SEP-99 female java java 40000
  • 4. QUERIES: 1.SQL> select avg(scost)from software where devin='oracle'; AVG(SCOST) ---------- 7000 2.SQL> select pname,trunc(months_between(sysdate,dob)/12)"age",trunc(months_between(sysdate,doj)/12)"experience "from programmer; PNAME age experience -------------------- ---------- ---------- sri 31 15 ferdy 34 22 shalini 31 14 harini 30 13 3.SQL> select pname from studies where course='PGDCA'; PNAME ------------------------------ mick sam 4.SQL> select max(sold) from software; MAX(SOLD) ---------- 200 5.SQL> select pname,dob from programmer where to_char(dob,’mon’)=’apr’; PNAME ---------------- Sri shalini 6.SQL> select min(ccost) from studies; MIN(CCOST) ---------- 3000
  • 5. 7.SQL> select count(*) from studies where course='DCA'; COUNT(*) ---------- 2 8.SQL> select sum(scost*sold-dcost) from software where devin='vb'; SUM(SCOST*SOLD-DCOST) --------------------- 2707000 9.SQL> select * from software where pname='rakesh'; PNAME TITLE -------------------- -------------------- DEVIN SCOST DCOST SOLD ---------------------------------------- ---------- ---------- ---------- rakesh inventory vb 10000 9000 200 10.SQL> select count(*) from studies where splace='pentafour'; COUNT(*) ---------- 1 11.SQL> select * from software where scost*sold-dcost>5000; PNAME TITLE -------------------- -------------------- DEVIN SCOST DCOST SOLD ---------------------------------------- ---------- ---------- ---------- raj Gtalk oracle 7000 5000 150 kumar chrome vb 6000 4000 120 mani db2 oracle 7000 5000 150 PNAME TITLE -------------------- --------------------
  • 6. DEVIN SCOST DCOST SOLD ---------------------------------------- ---------- ---------- ---------- rakesh inventory vb 10000 9000 200 12.SQL> select ceil(dcost/scost) from software; CEIL(DCOST/SCOST) ----------------- 1 1 1 1 13.SQL> select *from software where scost*sold>=dcost; PNAME TITLE -------------------- -------------------- DEVIN SCOST DCOST SOLD ---------------------------------------- ---------- ---------- ---------- raj Gtalk oracle 7000 5000 150 kumar chrome vb 6000 4000 120 mani db2 oracle 7000 5000 150 PNAME TITLE -------------------- -------------------- DEVIN SCOST DCOST SOLD ---------------------------------------- ---------- ---------- ---------- rakesh inventory vb 10000 9000 200 14.SQL> select max(scost) from software where devin='vb'; MAX(SCOST) ---------- 10000
  • 7. 15.SQL> select avg(scost) from software where devin='oracle'; AVG(SCOST) ---------- 7000 16.SQL> select count(*) from studies where splace='pragathi'; COUNT(*) ---------- 1 17.SQL> select count(*) from studies where ccost between 9000 and 16000; COUNT(*) ---------- 2 18.SQL> select avg(ccost) from studies; AVG(CCOST) ---------- 8000 19.SQL> select pname from programmer where prof1='c'or prof2='c'; PNAME -------------------- sri shalini 20.SQL> select count(pname) from programmer where prof1 in('c','pascal')or prof2 in('c','pascal'); COUNT(PNAME) ------------ 3 21.SQL> select count(pname) from programmer where prof1 not in('c','c++')or prof2 not in('c','c++'); COUNT(PNAME) ------------ 2
  • 8. 22.SQL> select round(max(months_between(sysdate,dob)/12)) from programmer where sex='male'; ROUND(MAX(MONTHS_BETWEEN(SYSDATE,DOB)/12)) ------------------------------------------ 34 23.SQL> select round(avg(months_between(sysdate,dob)/12)) from programmer where sex='female'; ROUND(AVG(MONTHS_BETWEEN(SYSDATE,DOB)/12)) ------------------------------------------ 31 24.SQL> select pname,trunc(months_between(sysdate,doj)/12) from programmer order by pname desc; PNAME TRUNC(MONTHS_BETWEEN(SYSDATE,DOJ)/12) -------------------- ------------------------------------- sri 15 shalini 14 harini 13 ferdy 22 25.SQL> select pname from programmer where to_char(dob,'mon')=to_char(sysdate,'mon'); PNAME -------------------- ferdy 26.SQL> select count(*) from programmer where sex='female'; COUNT(*) ---------- 2 27.SQL> select distinct(prof1) from programmer where sex='male'; PROF1 ------------------------------ c c++
  • 9. 28.SQL> select avg(sal) from programmer; AVG(SAL) ---------- 35000 29.SQL> select count(*) from programmer where sal between 20000 and 40000; COUNT(*) ---------- 3 30.SQL> select * from programmer where prof1 not in('c','c++','pascal') and prof2 not in('c','c++','pascal'); PNAME DOB DOJ SEX PROF1 -------------------- --------- --------- ------- ------------------------------ PROF2 SAL -------------------- ---------- harini 11-MAY-82 19-SEP-99 female java java 40000 31.SQL> select pname,title,scost from software where scost in(select max(scost) from software); PNAME TITLE SCOST -------------------- -------------------- ---------- rakesh inventory 10000 32.SQL> select 'Mr.'|| pname||'-has' || trunc(months_between(sysdate,doj)/12) || 'yeares of experience'"programmer" from programmer where sex='male'; programmer -------------------------------------------------------------------------------- Mr.sri-has15yeares of experience Mr.ferdy-has22yeares of experience SQL> spool off