SlideShare a Scribd company logo
1 of 4
CLAUSES: 
There are totally 4 types of clauses are present in SQLSERVER those are 
1. GROUPBY 
2. ORDERBY 
3. WHERE 
4. HAVING 
Create Database Practice DB 
GO 
Create Table EMPLOYEE 
Go 
Insert into EMPLOYEE values (EName VARCHAR (10), SAL VARCHAR (MAX), JOB VARCHAR (15), 
DEPTNO INT) 
GO 
insert DEPARTMENT values(‘RAGHU’,3000,’CLERK’,10), (‘SATISH’,80000,’MANAGER’,10), 
(‘KIRAN’,9000,’CLERK’,30), (‘RAVI’,30000,’ACCOUNTANT’,30), (‘ASHOK’,2000,’MANAGER’,20), 
(‘PRABHA’,17000,’ACCOUNTANT’,20), (‘RADHA’,13000,’CLERK’,20) 
GO 
ORDERBY: 
It is used to display Records in the table in ascending order or descending order 
SYNTAX: 
SELECT statement 
ORDERBY<coloumn_name> [DESC] 
EXAMPLE QUERIES: 
TO CREATE DUPLICATE TABLE ANS STORE SALARIES IN ASCENDING 
ORDER 
SYNTAX:
SELECT * INTO<DUPLICATE_TABLE> 
FROM<OLD_TABLE> 
SELECT * INTO EMPLIST 
FROM EMPLOYEE ORDERBY SAL 
IN SQLSERVER 2012 duplicate table will not work. 
TO GET NAMES IN ALPHABETICAL ORDER 
SELECT * FROM EMPLOYEE 
ORDER BY ENAME 
TO GET SALARIES IN ASCENDING ORDER 
SELECT * FROM EMPLOYEE 
ORDER BY SAL 
TO GET SALARIES IN DESCENDING ORDER 
SELECT * FROM EMPLOYEE 
ORDER BY SAL DESC 
TO GET SALARIES IN ASCENDING ORDER WITH DEPTNO 
SELECT * FROM EMPLOYEE 
WHERE DEPTNO=10 
ORDER BY SAL 
TO DISPLAY SALARIES BASED ON JOB 
SELECT * FROM EMPLOYEE 
ORDER BY JOB.SAL 
TO GET THREE HIGHEST SALARIES FROM EMPLOYEE TABLE 
SELECT TOP3 SAL FROM EMPLOYEE 
ORDERBY SAL DESC 
TO GET LAST 3 RECORDS FROM EMPLOYEE TABLE 
SELECT * FROM EMPLOYEE 
ORDER BY ENO
OFFSET 3 ROWS 
FETCH NEXT 3 ROWS ONLY 
NOTE:FETCH AND OFFSET COMMANDS WILL WORK ONLY IN SQLSERVER 2012. 
TO GET SALARIES IN ASCENDING ORDER BASED ON THE GIVEN COLOUMN INDEX 
VALUE 
SELECT * FROM EMPLOYEE 
ORDER BY 6 
GROUPBY: 
1. Ii is used to group duplicate values or similar values existing in the columns of the table 
2. With GROUPBY statement GROUP OR AGGRIGATE functions will be used. They are used to work on 
multiple values or multiple rows in the table. 
The functions are SUM(),AVG(),MAX(),M IN(),COUNT (),STDEV(),VA R()…etc. 
SYNATAX: 
SELECT STATEMENT 
GROUPBY<COLOUMN NAME> 
[HAVING CLAUSE] 
TO GET COUNT OF EMPLOYEE IN EACH DEPARTMENNT 
SELECT DEPTNO,COUNT(*)FROM EMPLOYEE 
GROUP BY DEPTNO 
OR 
SELECT DEPTNO,COUNT(JOB)no_of_emp(TEMPORARY COLUMN NAME USED) HERE FROM 
EMPLOYEE 
GROUPBY DEPTNO
TO GET COUNT OF EMPLOYEES WITH DEPTNO 10 
SELECT DEPTNO,COUNT(DEPTNO) FROM EMPLOYEE 
WHERE DEPT NO=10 
GROUPBY DEPTNO 
OR 
HAVING DEPTNO=10 
TO GET COUNT OF EMPLOYEES ONLY WHEN THE COUNT IS GREATER THAN 3 
SELECT DEPTNO,COUNT(DEPTNO)FROM EMPLOYEE 
GROUPBY DEPTNO 
HAVING COUNT(DEPTNO)>3 
TO GET COUNT OF EMPLOYEES IN EACH JOB 
SELECT JOB,COUNT(JOB)FROM EMPLOYEE 
GROUPBY JOB 
TO GET HIGHEST SALARY FROM EACH DEPARTEMENT 
SELECT DEPTNO,MAX(SAL) FROM EMPLOYEE 
GROUPBY DEPTNO 
TO GET HIGHEST SALARY FROM EACH JOB 
SELECT JOB,MAX(SAL) FROM EMPLOYEE 
GROUPBY JOB 
TO GET HIGHEST SALARY FROM EACH JOB AND DISPLAY SALARIES IN 
ASCENDING ORDER 
SELECT JOB,MAX(SAL) FROM EMPLOYEE 
GROUPBY JOB 
ORDERBY MAX(SAL) 
OR 
SELECT JOB,MAX(SAL) FROM EMPLOYEE 
GROUPBY JOB 
ORDERBY SAL

More Related Content

What's hot (20)

Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sql
 
Sql task answers
Sql task answersSql task answers
Sql task answers
 
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
 
SQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question BankSQL-RDBMS Queries and Question Bank
SQL-RDBMS Queries and Question Bank
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
 
80 different SQL Queries with output
80 different SQL Queries with output80 different SQL Queries with output
80 different SQL Queries with output
 
Les18
Les18Les18
Les18
 
Array menu
Array menuArray menu
Array menu
 
Sql queires
Sql queiresSql queires
Sql queires
 
Performante Java Enterprise Applikationen trotz O/R-Mapping
Performante Java Enterprise Applikationen trotz O/R-MappingPerformante Java Enterprise Applikationen trotz O/R-Mapping
Performante Java Enterprise Applikationen trotz O/R-Mapping
 
Structured query language(sql)
Structured query language(sql)Structured query language(sql)
Structured query language(sql)
 
PL/SQL Blocks
PL/SQL BlocksPL/SQL Blocks
PL/SQL Blocks
 
SQL BASIC QUERIES SOLUTION ~hmftj
SQL BASIC QUERIES SOLUTION ~hmftjSQL BASIC QUERIES SOLUTION ~hmftj
SQL BASIC QUERIES SOLUTION ~hmftj
 
array implementation
 array implementation array implementation
array implementation
 
My Sql
My Sql My Sql
My Sql
 
Top 40 sql queries for testers
Top 40 sql queries for testersTop 40 sql queries for testers
Top 40 sql queries for testers
 
Sql wksht-5
Sql wksht-5Sql wksht-5
Sql wksht-5
 
Use shop
Use shopUse shop
Use shop
 
SQL BASIC QUERIES
SQL  BASIC QUERIES SQL  BASIC QUERIES
SQL BASIC QUERIES
 

Viewers also liked (18)

Asp.net
Asp.netAsp.net
Asp.net
 
CRM and ERP
CRM and ERPCRM and ERP
CRM and ERP
 
Triggers
TriggersTriggers
Triggers
 
collections
 collections collections
collections
 
Joins
JoinsJoins
Joins
 
MOM on BA
MOM on BAMOM on BA
MOM on BA
 
Built in functions
Built in functionsBuilt in functions
Built in functions
 
MOM on activity diagram
MOM on activity diagramMOM on activity diagram
MOM on activity diagram
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
access modifiers
access modifiersaccess modifiers
access modifiers
 
Tools used by ba
Tools used by baTools used by ba
Tools used by ba
 
Bill Gates
Bill GatesBill Gates
Bill Gates
 
exception handling
 exception handling exception handling
exception handling
 
Business Analyst
Business AnalystBusiness Analyst
Business Analyst
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
System development life cycle
System development life cycleSystem development life cycle
System development life cycle
 
Business Analyst Documentation
Business Analyst DocumentationBusiness Analyst Documentation
Business Analyst Documentation
 
Business analyst ppt
Business analyst pptBusiness analyst ppt
Business analyst ppt
 

Similar to Clauses

Similar to Clauses (20)

Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
 
12. Basic SQL Queries (2).pptx
12. Basic SQL Queries  (2).pptx12. Basic SQL Queries  (2).pptx
12. Basic SQL Queries (2).pptx
 
Complex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptxComplex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptx
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Les04
Les04Les04
Les04
 
SQL
SQLSQL
SQL
 
Les04
Les04Les04
Les04
 
Les05
Les05Les05
Les05
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
sql language
sql languagesql language
sql language
 
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek SharmaIntroduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
 
Dynamic websites lec2
Dynamic websites lec2Dynamic websites lec2
Dynamic websites lec2
 
Exploring collections with example
Exploring collections with exampleExploring collections with example
Exploring collections with example
 
ORACLE NOTES
ORACLE NOTESORACLE NOTES
ORACLE NOTES
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
Module03
Module03Module03
Module03
 
Les17
Les17Les17
Les17
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 
Sql server ___________session 3(sql 2008)
Sql server  ___________session 3(sql 2008)Sql server  ___________session 3(sql 2008)
Sql server ___________session 3(sql 2008)
 

More from Yaswanth Babu Gummadivelli (17)

Presentation on BA
Presentation on BAPresentation on BA
Presentation on BA
 
ERP
ERPERP
ERP
 
Ba -content
Ba -contentBa -content
Ba -content
 
E commerce use case documentation.
E commerce use case documentation.E commerce use case documentation.
E commerce use case documentation.
 
Constructors
Constructors Constructors
Constructors
 
array
array array
array
 
Use case for atm
Use case for atmUse case for atm
Use case for atm
 
use case diagramHospital managment system
use case diagramHospital managment systemuse case diagramHospital managment system
use case diagramHospital managment system
 
Activity diagram for ticket vending machine
Activity diagram for ticket vending machineActivity diagram for ticket vending machine
Activity diagram for ticket vending machine
 
Extreme programming
Extreme programmingExtreme programming
Extreme programming
 
Agile model
Agile model Agile model
Agile model
 
Reflection
ReflectionReflection
Reflection
 
Exceptions in SQL Server
Exceptions in SQL ServerExceptions in SQL Server
Exceptions in SQL Server
 
Views
ViewsViews
Views
 
Subqueries
SubqueriesSubqueries
Subqueries
 
Set operators
Set operatorsSet operators
Set operators
 
Indexes
IndexesIndexes
Indexes
 

Recently uploaded

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 

Recently uploaded (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

Clauses

  • 1. CLAUSES: There are totally 4 types of clauses are present in SQLSERVER those are 1. GROUPBY 2. ORDERBY 3. WHERE 4. HAVING Create Database Practice DB GO Create Table EMPLOYEE Go Insert into EMPLOYEE values (EName VARCHAR (10), SAL VARCHAR (MAX), JOB VARCHAR (15), DEPTNO INT) GO insert DEPARTMENT values(‘RAGHU’,3000,’CLERK’,10), (‘SATISH’,80000,’MANAGER’,10), (‘KIRAN’,9000,’CLERK’,30), (‘RAVI’,30000,’ACCOUNTANT’,30), (‘ASHOK’,2000,’MANAGER’,20), (‘PRABHA’,17000,’ACCOUNTANT’,20), (‘RADHA’,13000,’CLERK’,20) GO ORDERBY: It is used to display Records in the table in ascending order or descending order SYNTAX: SELECT statement ORDERBY<coloumn_name> [DESC] EXAMPLE QUERIES: TO CREATE DUPLICATE TABLE ANS STORE SALARIES IN ASCENDING ORDER SYNTAX:
  • 2. SELECT * INTO<DUPLICATE_TABLE> FROM<OLD_TABLE> SELECT * INTO EMPLIST FROM EMPLOYEE ORDERBY SAL IN SQLSERVER 2012 duplicate table will not work. TO GET NAMES IN ALPHABETICAL ORDER SELECT * FROM EMPLOYEE ORDER BY ENAME TO GET SALARIES IN ASCENDING ORDER SELECT * FROM EMPLOYEE ORDER BY SAL TO GET SALARIES IN DESCENDING ORDER SELECT * FROM EMPLOYEE ORDER BY SAL DESC TO GET SALARIES IN ASCENDING ORDER WITH DEPTNO SELECT * FROM EMPLOYEE WHERE DEPTNO=10 ORDER BY SAL TO DISPLAY SALARIES BASED ON JOB SELECT * FROM EMPLOYEE ORDER BY JOB.SAL TO GET THREE HIGHEST SALARIES FROM EMPLOYEE TABLE SELECT TOP3 SAL FROM EMPLOYEE ORDERBY SAL DESC TO GET LAST 3 RECORDS FROM EMPLOYEE TABLE SELECT * FROM EMPLOYEE ORDER BY ENO
  • 3. OFFSET 3 ROWS FETCH NEXT 3 ROWS ONLY NOTE:FETCH AND OFFSET COMMANDS WILL WORK ONLY IN SQLSERVER 2012. TO GET SALARIES IN ASCENDING ORDER BASED ON THE GIVEN COLOUMN INDEX VALUE SELECT * FROM EMPLOYEE ORDER BY 6 GROUPBY: 1. Ii is used to group duplicate values or similar values existing in the columns of the table 2. With GROUPBY statement GROUP OR AGGRIGATE functions will be used. They are used to work on multiple values or multiple rows in the table. The functions are SUM(),AVG(),MAX(),M IN(),COUNT (),STDEV(),VA R()…etc. SYNATAX: SELECT STATEMENT GROUPBY<COLOUMN NAME> [HAVING CLAUSE] TO GET COUNT OF EMPLOYEE IN EACH DEPARTMENNT SELECT DEPTNO,COUNT(*)FROM EMPLOYEE GROUP BY DEPTNO OR SELECT DEPTNO,COUNT(JOB)no_of_emp(TEMPORARY COLUMN NAME USED) HERE FROM EMPLOYEE GROUPBY DEPTNO
  • 4. TO GET COUNT OF EMPLOYEES WITH DEPTNO 10 SELECT DEPTNO,COUNT(DEPTNO) FROM EMPLOYEE WHERE DEPT NO=10 GROUPBY DEPTNO OR HAVING DEPTNO=10 TO GET COUNT OF EMPLOYEES ONLY WHEN THE COUNT IS GREATER THAN 3 SELECT DEPTNO,COUNT(DEPTNO)FROM EMPLOYEE GROUPBY DEPTNO HAVING COUNT(DEPTNO)>3 TO GET COUNT OF EMPLOYEES IN EACH JOB SELECT JOB,COUNT(JOB)FROM EMPLOYEE GROUPBY JOB TO GET HIGHEST SALARY FROM EACH DEPARTEMENT SELECT DEPTNO,MAX(SAL) FROM EMPLOYEE GROUPBY DEPTNO TO GET HIGHEST SALARY FROM EACH JOB SELECT JOB,MAX(SAL) FROM EMPLOYEE GROUPBY JOB TO GET HIGHEST SALARY FROM EACH JOB AND DISPLAY SALARIES IN ASCENDING ORDER SELECT JOB,MAX(SAL) FROM EMPLOYEE GROUPBY JOB ORDERBY MAX(SAL) OR SELECT JOB,MAX(SAL) FROM EMPLOYEE GROUPBY JOB ORDERBY SAL