SlideShare a Scribd company logo
UNIT 3.3 SQL COMMANDS
INTRODUCTION :: My SQL is RDBMS that uses SQL to access
the data. It is downloaded from www.mysql.org.MySQL was
invented by Michael Widenius. The logo of My SQL is ,the
Dolphin.SQL stands for Structured Query Language. Initially SQL
was called Sequel.
MEANING :: SQL is simple query language used for accessing,
managing and handling data in relation database.
CLASSIFICATION OF SQL STATEMENTS :: SQL commands
can be divided into following categories.
1. Data Definition Language(DDL)
2. Data Manipulation Language(DML)
3. Data Control Language(DCL)
4. Transaction Control Language(TCL)
Data Definition language(DDL) :: (Defines storage structure.)
 Create
 Alter
 Drop
 Truncate
Data Manipulation Language(DML):: (Used to access and
manipulate data.)
 Select
 Insert
 Update
 Delete
Data Control Language(DCL)::
 Grant
 Revoke
Transaction Control Language(TCL)::
 Commit
 Rollback
 Savepoint
DATA DICTIONARY:: Data Dictionary contains data about
database. Data Dictionary contains information about tables. It
contains result of compilation of DDL statements.
Metadata means data about data.
Concept of Data type:: Data types indicate the type of value
the field will contain.
String, Character and date must always be enclosed in
single quotes/double quotes.
Difference between Char and Varchar :: Char refers to
Character and Varchar refers to Variable Character.
Char(7) – It always take 7 bytes of data whether you are
storing one character or 7 character. There is wastage of
space. Char is fixed length data type.
Varchar(10) – If you are storing one character then it will take
only one byte and if you are storing ten character then it will
take ten bytes. There is no wastage of space. Extra space is
automatically removed. Varchar is variable length data type.
Null Values :: If a column has no value then column is said to
be null. If column is assign as primary key then it must not
Null.
Comments :: Comments used in SQL are
/* text */ (for multiple lines)
# (for single lines)
-- (for single lines) and must be followed by a space
SQL Command Syntax ::
Keyword(select , insert…….)
Statements
Clauses(from , where)
Argument(where sales=5000) sales=5000 is an argument.
Grouping Result : Group by clause :: Group by clause
is used to divide the table into groups.
Table::emp
select job , count(*) , sum(comm)
from emp
group by job;
emp no empname Job hiredate sal comm deptno
7839 King President 17-Nov-81 5000 NULL
7698 Blake Manager 01-May-81 2850 80
7782 Clark Manager 09-June-81 2800 NULL
7566 Jones Manager 12-Apr-81 2450 21
7564 Martin Salesman 28-Sep-81 1250 1400 30
7499 Allen Salesman 20-Sep-81 1600 300 30
job count(*) sum(comm)
President 1 0
Manager 3 0
Salesman 2 1700
Placing condition on groups – having clause
select grade , avg(gross) , sum(gross)
from employee
group by grade
having grade=‘E2’;
grade avg(gross) sum(gross)
E2 8500 17000
Select job , count(*)
from emp
group by job
having count(*)<3;
Functions used in SQL ::
Avg :: Compute average value
Min :: Find minimum value
Max :: Find maximum value
job count(*)
Presidnt 1
Salesman 2
Sum :: Find total value
Count :: to count NOT NULL values in a column
Count(*) :: to count total number of rows in a table
Joins:: A join is a query that combines rows from two
or more tables. In a join query , more than one table
are listed in from clause.
View Command ::
View is a Virtual table with no data. If data is changing in
underlying table, the same change is reflect in view.
create view taxpayee as
select * from employee
where gross>8000;
taxpayee is a view(virtual table) that contain details of those
employees from employee table that have gross > 8000
Select * from taxpayee;
This query dislays all rows present in view.
If any column in the view is to be given a different name
other than the name of the column from which it is delivered,
it is done as follows.
create view taxpayee
(empcode, empname, sex, empgrade, empgross) as
select * from employee
where gross > 8000;
create view taxpayee(ecode,ename,tax) as
select ecode,ename,gross*.1
from employee
Where gross > 8000;
The above created view has an additional column tax
which is 10% of the gross
You can use insert , delete , update command on view
Assignment – 5
Consider the following tables games and players and answer (a) and (b) part of this
question.
TABLE :: Games
TABLE :: Players
Gcode Gname Type Number PrizeMoney Scheduled date
101 Carrom Board Indoor 2 5000 23-Jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003
103 Table Tennis Indoor 4 8000 14-Feb-2004
105 Chess Indoor 2 9000 1-Jan-2004
108 Lawn Tennis Outdoor 4 25000 19-Mar-2004
Pcode Name Gcod
e
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazreen 103
(a) Write SQL commands for the following statement
(i) To display the name of all Games with their Gcode.
(ii) To display details of those Games which are having PrizeMoney
more than 7000
(iii) To display the content of the Games table in ascending order of
Schedule date
(iv) To display sum of PrizeMoney for each type of Games.
(b) Give the output of the following SQL Queries
(i) Select count(distinct Number) from Games;
(ii) Select max(Schedule date), min(Schedule date);
(iii) Select Name Gname from Game G Players P
Where G.Gcode=P.Gcode and G.PrizeMoney>10000;
(iv) Select distinct Gcode from Players;
Assignment - 7
SQL (1).pptx

More Related Content

Similar to SQL (1).pptx

lect 2.pptx
lect 2.pptxlect 2.pptx
lect 2.pptx
HermanGaming
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
Microsoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptxMicrosoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptx
HaribabuKonakanchi1
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
Keshav Murthy
 
Oracle notes
Oracle notesOracle notes
Oracle notes
Prashant Dadmode
 
Sq lite functions
Sq lite functionsSq lite functions
Sq lite functionspunu_82
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql newSANTOSH RATH
 
Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
mukesh24pandey
 
Lab
LabLab
Mysqlppt
MysqlpptMysqlppt
MysqlpptReka
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
Bwsrang Basumatary
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
pradnyamulay
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016Mir Mahmood
 
SQL Database Performance Tuning for Developers
SQL Database Performance Tuning for DevelopersSQL Database Performance Tuning for Developers
SQL Database Performance Tuning for Developers
BRIJESH KUMAR
 
Module 02 teradata basics
Module 02 teradata basicsModule 02 teradata basics
Module 02 teradata basics
Md. Noor Alam
 
Dbms
DbmsDbms

Similar to SQL (1).pptx (20)

Sql 2006
Sql 2006Sql 2006
Sql 2006
 
lect 2.pptx
lect 2.pptxlect 2.pptx
lect 2.pptx
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Microsoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptxMicrosoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptx
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
IBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql FeaturesIBM Informix dynamic server 11 10 Cheetah Sql Features
IBM Informix dynamic server 11 10 Cheetah Sql Features
 
Oracle notes
Oracle notesOracle notes
Oracle notes
 
Sq lite functions
Sq lite functionsSq lite functions
Sq lite functions
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
 
Lab
LabLab
Lab
 
Les09
Les09Les09
Les09
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016
 
SQL Database Performance Tuning for Developers
SQL Database Performance Tuning for DevelopersSQL Database Performance Tuning for Developers
SQL Database Performance Tuning for Developers
 
Module 02 teradata basics
Module 02 teradata basicsModule 02 teradata basics
Module 02 teradata basics
 
Mysql Ppt
Mysql PptMysql Ppt
Mysql Ppt
 
Dbms
DbmsDbms
Dbms
 

Recently uploaded

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

SQL (1).pptx

  • 1. UNIT 3.3 SQL COMMANDS INTRODUCTION :: My SQL is RDBMS that uses SQL to access the data. It is downloaded from www.mysql.org.MySQL was invented by Michael Widenius. The logo of My SQL is ,the Dolphin.SQL stands for Structured Query Language. Initially SQL was called Sequel. MEANING :: SQL is simple query language used for accessing, managing and handling data in relation database. CLASSIFICATION OF SQL STATEMENTS :: SQL commands can be divided into following categories. 1. Data Definition Language(DDL) 2. Data Manipulation Language(DML)
  • 2. 3. Data Control Language(DCL) 4. Transaction Control Language(TCL) Data Definition language(DDL) :: (Defines storage structure.)  Create  Alter  Drop  Truncate Data Manipulation Language(DML):: (Used to access and manipulate data.)  Select  Insert  Update  Delete
  • 3. Data Control Language(DCL)::  Grant  Revoke Transaction Control Language(TCL)::  Commit  Rollback  Savepoint DATA DICTIONARY:: Data Dictionary contains data about database. Data Dictionary contains information about tables. It contains result of compilation of DDL statements. Metadata means data about data. Concept of Data type:: Data types indicate the type of value the field will contain.
  • 4.
  • 5. String, Character and date must always be enclosed in single quotes/double quotes. Difference between Char and Varchar :: Char refers to Character and Varchar refers to Variable Character. Char(7) – It always take 7 bytes of data whether you are storing one character or 7 character. There is wastage of space. Char is fixed length data type. Varchar(10) – If you are storing one character then it will take only one byte and if you are storing ten character then it will take ten bytes. There is no wastage of space. Extra space is automatically removed. Varchar is variable length data type.
  • 6. Null Values :: If a column has no value then column is said to be null. If column is assign as primary key then it must not Null. Comments :: Comments used in SQL are /* text */ (for multiple lines) # (for single lines) -- (for single lines) and must be followed by a space SQL Command Syntax :: Keyword(select , insert…….) Statements Clauses(from , where) Argument(where sales=5000) sales=5000 is an argument.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34. Grouping Result : Group by clause :: Group by clause is used to divide the table into groups. Table::emp select job , count(*) , sum(comm) from emp group by job; emp no empname Job hiredate sal comm deptno 7839 King President 17-Nov-81 5000 NULL 7698 Blake Manager 01-May-81 2850 80 7782 Clark Manager 09-June-81 2800 NULL 7566 Jones Manager 12-Apr-81 2450 21 7564 Martin Salesman 28-Sep-81 1250 1400 30 7499 Allen Salesman 20-Sep-81 1600 300 30
  • 35. job count(*) sum(comm) President 1 0 Manager 3 0 Salesman 2 1700 Placing condition on groups – having clause select grade , avg(gross) , sum(gross) from employee group by grade having grade=‘E2’; grade avg(gross) sum(gross) E2 8500 17000
  • 36. Select job , count(*) from emp group by job having count(*)<3; Functions used in SQL :: Avg :: Compute average value Min :: Find minimum value Max :: Find maximum value job count(*) Presidnt 1 Salesman 2
  • 37. Sum :: Find total value Count :: to count NOT NULL values in a column Count(*) :: to count total number of rows in a table Joins:: A join is a query that combines rows from two or more tables. In a join query , more than one table are listed in from clause.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47. View Command :: View is a Virtual table with no data. If data is changing in underlying table, the same change is reflect in view. create view taxpayee as select * from employee where gross>8000; taxpayee is a view(virtual table) that contain details of those employees from employee table that have gross > 8000 Select * from taxpayee; This query dislays all rows present in view.
  • 48. If any column in the view is to be given a different name other than the name of the column from which it is delivered, it is done as follows. create view taxpayee (empcode, empname, sex, empgrade, empgross) as select * from employee where gross > 8000; create view taxpayee(ecode,ename,tax) as select ecode,ename,gross*.1 from employee Where gross > 8000;
  • 49. The above created view has an additional column tax which is 10% of the gross You can use insert , delete , update command on view
  • 50. Assignment – 5 Consider the following tables games and players and answer (a) and (b) part of this question. TABLE :: Games TABLE :: Players Gcode Gname Type Number PrizeMoney Scheduled date 101 Carrom Board Indoor 2 5000 23-Jan-2004 102 Badminton Outdoor 2 12000 12-Dec-2003 103 Table Tennis Indoor 4 8000 14-Feb-2004 105 Chess Indoor 2 9000 1-Jan-2004 108 Lawn Tennis Outdoor 4 25000 19-Mar-2004 Pcode Name Gcod e 1 Nabi Ahmad 101 2 Ravi Sahai 108 3 Jatin 101 4 Nazreen 103
  • 51. (a) Write SQL commands for the following statement (i) To display the name of all Games with their Gcode. (ii) To display details of those Games which are having PrizeMoney more than 7000 (iii) To display the content of the Games table in ascending order of Schedule date (iv) To display sum of PrizeMoney for each type of Games. (b) Give the output of the following SQL Queries (i) Select count(distinct Number) from Games; (ii) Select max(Schedule date), min(Schedule date); (iii) Select Name Gname from Game G Players P Where G.Gcode=P.Gcode and G.PrizeMoney>10000; (iv) Select distinct Gcode from Players;