SlideShare uma empresa Scribd logo
1 de 23
SQL SELECT DISTINCT
Statement
 In a table, some of the columns may contain
duplicate values. This is not a problem,
however, sometimes you will want to list only
the different (distinct) values in a table.
 The DISTINCT keyword can be used to return
only distinct (different) values.
 SQL SELECT DISTINCT Syntax
SELECT DISTINCT column_name(s)
FROM table_name
SELECT DISTINCT Person.PName
FROM Person;
Id Name Address Hobby
1123 Anita Damauli stamps
1123 Anita Damauli coins
5556 Binod
Kathmand
u
hiking
9876 Barsha
Kathmand
u
stamps
PName
Anita
Barsha
Binod
SQL AND & OR Operators
 The AND & OR operators are used to filter
records based on more than one condition
 The AND operator displays a record if both the
first condition and the second condition are
true.
 The OR operator displays a record if either the
first condition or the second condition is true.
SQL OR Operators
SELECT * FROM Person
WHERE Person.Hobby='hiking' OR
Person.ID>3000;
ID PName Address Hobby
5556 Binod Kathmandu hiking
9876 Barsha Kathmandu stamps
SQL AND Operators
SELECT *
FROM Person
WHERE Person.ID>3000 AND Person.ID<5999;
ID PName Address Hobby
5556 Binod Kathmandu hiking
SQL ORDER BY
 The ORDER BY keyword is used to sort the
result-set.
 The ORDER BY keyword is used to sort the
result-set by a specified column.
 The ORDER BY keyword sorts the records in
ascending order by default.
 If you want to sort the records in a descending
order, you can use the DESC keyword.
SQL ORDER BY Syntax
 SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC
SELECT Person.Hobby
FROM Person
ORDER BY Person.Hobby;
Hobby
coins
hiking
stamps
stamps
SQL INSERT INTO
 The INSERT INTO statement is used to insert a new
row in a table.
SQL INSERT INTO Syntax
 It is possible to write the INSERT INTO statement in
two forms.
 The first form doesn't specify the column names
where the data will be inserted, only their values:
INSERT INTO table_name VALUES (value1, value2,
value3,...)
 The second form specifies both the column names
and the values to be inserted:
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)
SQL INSERT INTO
 INSERT INTO Persons
VALUES (4,'Nilsen', 'Johan', 'Bakken 2',
'Stavanger')
 INSERT INTO Persons (P_Id, LastName,
FirstName)
VALUES (5, 'Tjessem', 'Jakob')
SQL UPDATE
The UPDATE statement is used to update
existing records in a table.
SQL UPDATE Syntax:
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Example:
UPDATE Persons
SET Address=‘Nayabazar', City=‘Kathmandu'
WHERE LastName=‘Ghimire' AND
FirstName=‘Bishal'
SQL UPDATE Warning
 Be careful when updating records. If we had
omitted the WHERE clause in the example
above, like this:
UPDATE Persons
SET Address=‘Nayabazar', City=‘Kathmandu‘
What will be the result ?
SQL DELETE
 The DELETE statement is used to delete rows
in a table.
SQL DELETE Syntax
DELETE FROM table_name
WHERE some_column=some_value
DELETE FROM Persons
WHERE Address=‘Nayabazar', City=‘Kathmandu‘
SQL TOP
 The TOP clause is used to specify the number
of records to return.
 The TOP clause can be very useful on large
tables with thousands of records. Returning a
large number of records can impact on
performance.
 Note: Not all database systems support the
TOP clause.
 SQL Server Syntax
 SELECT TOP number|percent column_name(s)
FROM table_name
SQL TOP
 MySQL Syntax
 SELECT column_name(s)
FROM table_name
LIMIT number
 Oracle Syntax
 SELECT column_name(s)
FROM table_name
WHERE ROWNUM <= number
 SELECT * FROM Persons LIMIT 5
SQL LIKE
 The LIKE operator is used to search for a
specified pattern in a column.
 SQL LIKE Syntax
 SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
SQL LIKE
 To select the persons living in a city that starts
with "s" from the table.
 SELECT * FROM Persons
WHERE City LIKE ‘k%'
SQL Wildcards
Wildcard Description
% A substitute for zero or more characters
_ A substitute for exactly one character
[charlist] Any single character in charlist
[^charlist]or
[!charlist]
Any single character not in charlist
• SQL wildcards can substitute for one or more
characters when searching for data in a
database.
• SQL wildcards must be used with the SQL
LIKE operator.
SQL IN
 The IN operator allows you to specify multiple
values in a WHERE clause.
 SQL IN Syntax
 SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...)
 Example #1
Select *
From Address
Where FirstName IN ('Mary', 'Sam')
 Example #2
SELECT *
FROM Address
WHERE FirstName = 'Mary'
OR FirstName = 'Sam'
SQL BETWEEN
 The BETWEEN operator selects a range of
data between two values. The values can be
numbers, text, or dates.
 SQL BETWEEN Syntax
 SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
 Example:
 SELECT * FROM suppliers WHERE supplier_id
BETWEEN 5000 AND 5010;
 SELECT * FROM suppliers WHERE supplier_id
>= 5000 AND supplier_id <= 5010;
 example:
 SELECT * FROM orders WHERE order_date
between to_date ('2013/01/01', 'yyyy/mm/dd')
AND to_date ('2013/12/31', 'yyyy/mm/dd');
 SELECT * FROM orders WHERE order_date >=
to_date('2013/01/01', 'yyyy/mm/dd') AND
order_date <=
to_date('2013/12/31','yyyy/mm/dd');

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
SQL JOIN
SQL JOINSQL JOIN
SQL JOIN
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL
SQLSQL
SQL
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
SQL
SQLSQL
SQL
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
basic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptxbasic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptx
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
SQL: DDL, DML y SQL
SQL: DDL, DML y SQLSQL: DDL, DML y SQL
SQL: DDL, DML y SQL
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base
 
sql function(ppt)
sql function(ppt)sql function(ppt)
sql function(ppt)
 
4. plsql
4. plsql4. plsql
4. plsql
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
 

Destaque

Prestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôléPrestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôléFondation iFRAP
 
嶺南 完成版 With Reference By Vince Cheung
嶺南 完成版 With Reference  By Vince Cheung嶺南 完成版 With Reference  By Vince Cheung
嶺南 完成版 With Reference By Vince Cheungalexwong1215
 
Setting Up Stock Broking Business in Vietnam
Setting Up Stock Broking Business in VietnamSetting Up Stock Broking Business in Vietnam
Setting Up Stock Broking Business in VietnamDennis Ooi
 
[Paper introduction] Performance Capture of Interacting Characters with Handh...
[Paper introduction] Performance Capture of Interacting Characters with Handh...[Paper introduction] Performance Capture of Interacting Characters with Handh...
[Paper introduction] Performance Capture of Interacting Characters with Handh...Mitsuru Nakazawa
 
Funding outlook for training providers by Safaraz Ali April 2015
Funding outlook for training providers by Safaraz Ali April 2015Funding outlook for training providers by Safaraz Ali April 2015
Funding outlook for training providers by Safaraz Ali April 2015The Pathway Group
 
15 May 2015
15 May 201515 May 2015
15 May 2015ssktimes
 
Knives, Sharpeners, Scissors, Graters and Hooks.
Knives, Sharpeners, Scissors, Graters and Hooks.Knives, Sharpeners, Scissors, Graters and Hooks.
Knives, Sharpeners, Scissors, Graters and Hooks.Eong Huat Indoor Sales
 
TestBird - Mobile Game Testing Report(Sample)
TestBird - Mobile Game Testing Report(Sample)TestBird - Mobile Game Testing Report(Sample)
TestBird - Mobile Game Testing Report(Sample)TestBird
 
Tmw20116 brooks.l
Tmw20116 brooks.lTmw20116 brooks.l
Tmw20116 brooks.lnavaidkhan
 
Resume: Research Engineer
Resume: Research Engineer Resume: Research Engineer
Resume: Research Engineer Abhishek Singh
 

Destaque (20)

Marketing pitch
Marketing pitchMarketing pitch
Marketing pitch
 
Prestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôléPrestations et aides sociales, le dérapage incontrôlé
Prestations et aides sociales, le dérapage incontrôlé
 
CIRCULAR IPC FEBRERO 2016
CIRCULAR IPC FEBRERO 2016CIRCULAR IPC FEBRERO 2016
CIRCULAR IPC FEBRERO 2016
 
嶺南 完成版 With Reference By Vince Cheung
嶺南 完成版 With Reference  By Vince Cheung嶺南 完成版 With Reference  By Vince Cheung
嶺南 完成版 With Reference By Vince Cheung
 
معلم التجويد
معلم التجويدمعلم التجويد
معلم التجويد
 
Setting Up Stock Broking Business in Vietnam
Setting Up Stock Broking Business in VietnamSetting Up Stock Broking Business in Vietnam
Setting Up Stock Broking Business in Vietnam
 
[Paper introduction] Performance Capture of Interacting Characters with Handh...
[Paper introduction] Performance Capture of Interacting Characters with Handh...[Paper introduction] Performance Capture of Interacting Characters with Handh...
[Paper introduction] Performance Capture of Interacting Characters with Handh...
 
Walden UDL PPT
Walden UDL PPTWalden UDL PPT
Walden UDL PPT
 
gghjkl
gghjklgghjkl
gghjkl
 
Funding outlook for training providers by Safaraz Ali April 2015
Funding outlook for training providers by Safaraz Ali April 2015Funding outlook for training providers by Safaraz Ali April 2015
Funding outlook for training providers by Safaraz Ali April 2015
 
15 May 2015
15 May 201515 May 2015
15 May 2015
 
Ee 2484i
Ee 2484iEe 2484i
Ee 2484i
 
Knives, Sharpeners, Scissors, Graters and Hooks.
Knives, Sharpeners, Scissors, Graters and Hooks.Knives, Sharpeners, Scissors, Graters and Hooks.
Knives, Sharpeners, Scissors, Graters and Hooks.
 
History and actors of nonviolence. — 06. From 1939 to 1949
History and actors of nonviolence. — 06. From 1939 to 1949History and actors of nonviolence. — 06. From 1939 to 1949
History and actors of nonviolence. — 06. From 1939 to 1949
 
TestBird - Mobile Game Testing Report(Sample)
TestBird - Mobile Game Testing Report(Sample)TestBird - Mobile Game Testing Report(Sample)
TestBird - Mobile Game Testing Report(Sample)
 
Apple 301
Apple 301Apple 301
Apple 301
 
Sfdfdf
SfdfdfSfdfdf
Sfdfdf
 
Tmw20116 brooks.l
Tmw20116 brooks.lTmw20116 brooks.l
Tmw20116 brooks.l
 
hlooooooo
hlooooooohlooooooo
hlooooooo
 
Resume: Research Engineer
Resume: Research Engineer Resume: Research Engineer
Resume: Research Engineer
 

Semelhante a 06.01 sql select distinct

Semelhante a 06.01 sql select distinct (20)

MY SQL
MY SQLMY SQL
MY SQL
 
Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01Mysql 120831075600-phpapp01
Mysql 120831075600-phpapp01
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
SQL notes 1.pdf
SQL notes 1.pdfSQL notes 1.pdf
SQL notes 1.pdf
 
SQL Tutorial for Beginners
SQL Tutorial for BeginnersSQL Tutorial for Beginners
SQL Tutorial for Beginners
 
SQL
SQLSQL
SQL
 
SQL
SQLSQL
SQL
 
SQL Language
SQL LanguageSQL Language
SQL Language
 
Query
QueryQuery
Query
 
MS SQL Server 1
MS SQL Server 1MS SQL Server 1
MS SQL Server 1
 
Sql slid
Sql slidSql slid
Sql slid
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Sql
SqlSql
Sql
 
SQL PPT.pptx
SQL PPT.pptxSQL PPT.pptx
SQL PPT.pptx
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
 
SQL report
SQL reportSQL report
SQL report
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsgADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
ADBMS unit 1.pdfsdgdsgdsgdsgdsgdsgdsgdsg
 
Bibashsql
BibashsqlBibashsql
Bibashsql
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
 

Mais de Bishal Ghimire

Counseling Ethics in Astrology for better Mental Health
Counseling Ethics in Astrology for better Mental HealthCounseling Ethics in Astrology for better Mental Health
Counseling Ethics in Astrology for better Mental HealthBishal Ghimire
 
Agile Intro to Manifesto - Values 1 - Interaction over Process
Agile Intro to Manifesto - Values 1 - Interaction over ProcessAgile Intro to Manifesto - Values 1 - Interaction over Process
Agile Intro to Manifesto - Values 1 - Interaction over ProcessBishal Ghimire
 
Earthquake in Nepal 2015
Earthquake in Nepal 2015Earthquake in Nepal 2015
Earthquake in Nepal 2015Bishal Ghimire
 
09.02 normalization example
09.02 normalization example09.02 normalization example
09.02 normalization exampleBishal Ghimire
 
07.03 cartesian product
07.03 cartesian product07.03 cartesian product
07.03 cartesian productBishal Ghimire
 
07.02 relational union intersection
07.02 relational union intersection07.02 relational union intersection
07.02 relational union intersectionBishal Ghimire
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebraBishal Ghimire
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebraBishal Ghimire
 
04.01 file organization
04.01 file organization04.01 file organization
04.01 file organizationBishal Ghimire
 
02.02 querying relational database
02.02 querying relational database02.02 querying relational database
02.02 querying relational databaseBishal Ghimire
 
02.01 relational databases
02.01 relational databases02.01 relational databases
02.01 relational databasesBishal Ghimire
 
01.01 introduction to database
01.01 introduction to database01.01 introduction to database
01.01 introduction to databaseBishal Ghimire
 
00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabus00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabusBishal Ghimire
 

Mais de Bishal Ghimire (17)

Counseling Ethics in Astrology for better Mental Health
Counseling Ethics in Astrology for better Mental HealthCounseling Ethics in Astrology for better Mental Health
Counseling Ethics in Astrology for better Mental Health
 
Agile Intro to Manifesto - Values 1 - Interaction over Process
Agile Intro to Manifesto - Values 1 - Interaction over ProcessAgile Intro to Manifesto - Values 1 - Interaction over Process
Agile Intro to Manifesto - Values 1 - Interaction over Process
 
Earthquake in Nepal 2015
Earthquake in Nepal 2015Earthquake in Nepal 2015
Earthquake in Nepal 2015
 
09.02 normalization example
09.02 normalization example09.02 normalization example
09.02 normalization example
 
07.05 division
07.05 division07.05 division
07.05 division
 
07.04 joins
07.04 joins07.04 joins
07.04 joins
 
07.03 cartesian product
07.03 cartesian product07.03 cartesian product
07.03 cartesian product
 
07.02 relational union intersection
07.02 relational union intersection07.02 relational union intersection
07.02 relational union intersection
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebra
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebra
 
09.01 normalization
09.01 normalization09.01 normalization
09.01 normalization
 
06.02 sql alias
06.02 sql alias06.02 sql alias
06.02 sql alias
 
04.01 file organization
04.01 file organization04.01 file organization
04.01 file organization
 
02.02 querying relational database
02.02 querying relational database02.02 querying relational database
02.02 querying relational database
 
02.01 relational databases
02.01 relational databases02.01 relational databases
02.01 relational databases
 
01.01 introduction to database
01.01 introduction to database01.01 introduction to database
01.01 introduction to database
 
00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabus00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabus
 

Último

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Último (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

06.01 sql select distinct

  • 1.
  • 2. SQL SELECT DISTINCT Statement  In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.  The DISTINCT keyword can be used to return only distinct (different) values.  SQL SELECT DISTINCT Syntax SELECT DISTINCT column_name(s) FROM table_name
  • 3. SELECT DISTINCT Person.PName FROM Person; Id Name Address Hobby 1123 Anita Damauli stamps 1123 Anita Damauli coins 5556 Binod Kathmand u hiking 9876 Barsha Kathmand u stamps PName Anita Barsha Binod
  • 4. SQL AND & OR Operators  The AND & OR operators are used to filter records based on more than one condition  The AND operator displays a record if both the first condition and the second condition are true.  The OR operator displays a record if either the first condition or the second condition is true.
  • 5. SQL OR Operators SELECT * FROM Person WHERE Person.Hobby='hiking' OR Person.ID>3000; ID PName Address Hobby 5556 Binod Kathmandu hiking 9876 Barsha Kathmandu stamps
  • 6. SQL AND Operators SELECT * FROM Person WHERE Person.ID>3000 AND Person.ID<5999; ID PName Address Hobby 5556 Binod Kathmandu hiking
  • 7. SQL ORDER BY  The ORDER BY keyword is used to sort the result-set.  The ORDER BY keyword is used to sort the result-set by a specified column.  The ORDER BY keyword sorts the records in ascending order by default.  If you want to sort the records in a descending order, you can use the DESC keyword.
  • 8. SQL ORDER BY Syntax  SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC SELECT Person.Hobby FROM Person ORDER BY Person.Hobby; Hobby coins hiking stamps stamps
  • 9. SQL INSERT INTO  The INSERT INTO statement is used to insert a new row in a table. SQL INSERT INTO Syntax  It is possible to write the INSERT INTO statement in two forms.  The first form doesn't specify the column names where the data will be inserted, only their values: INSERT INTO table_name VALUES (value1, value2, value3,...)  The second form specifies both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)
  • 10. SQL INSERT INTO  INSERT INTO Persons VALUES (4,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger')  INSERT INTO Persons (P_Id, LastName, FirstName) VALUES (5, 'Tjessem', 'Jakob')
  • 11. SQL UPDATE The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax: UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value Example: UPDATE Persons SET Address=‘Nayabazar', City=‘Kathmandu' WHERE LastName=‘Ghimire' AND FirstName=‘Bishal'
  • 12. SQL UPDATE Warning  Be careful when updating records. If we had omitted the WHERE clause in the example above, like this: UPDATE Persons SET Address=‘Nayabazar', City=‘Kathmandu‘ What will be the result ?
  • 13. SQL DELETE  The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value DELETE FROM Persons WHERE Address=‘Nayabazar', City=‘Kathmandu‘
  • 14. SQL TOP  The TOP clause is used to specify the number of records to return.  The TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance.  Note: Not all database systems support the TOP clause.  SQL Server Syntax  SELECT TOP number|percent column_name(s) FROM table_name
  • 15. SQL TOP  MySQL Syntax  SELECT column_name(s) FROM table_name LIMIT number  Oracle Syntax  SELECT column_name(s) FROM table_name WHERE ROWNUM <= number  SELECT * FROM Persons LIMIT 5
  • 16. SQL LIKE  The LIKE operator is used to search for a specified pattern in a column.  SQL LIKE Syntax  SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern
  • 17. SQL LIKE  To select the persons living in a city that starts with "s" from the table.  SELECT * FROM Persons WHERE City LIKE ‘k%'
  • 18. SQL Wildcards Wildcard Description % A substitute for zero or more characters _ A substitute for exactly one character [charlist] Any single character in charlist [^charlist]or [!charlist] Any single character not in charlist • SQL wildcards can substitute for one or more characters when searching for data in a database. • SQL wildcards must be used with the SQL LIKE operator.
  • 19. SQL IN  The IN operator allows you to specify multiple values in a WHERE clause.  SQL IN Syntax  SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...)
  • 20.  Example #1 Select * From Address Where FirstName IN ('Mary', 'Sam')  Example #2 SELECT * FROM Address WHERE FirstName = 'Mary' OR FirstName = 'Sam'
  • 21. SQL BETWEEN  The BETWEEN operator selects a range of data between two values. The values can be numbers, text, or dates.  SQL BETWEEN Syntax  SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2
  • 22.  Example:  SELECT * FROM suppliers WHERE supplier_id BETWEEN 5000 AND 5010;  SELECT * FROM suppliers WHERE supplier_id >= 5000 AND supplier_id <= 5010;
  • 23.  example:  SELECT * FROM orders WHERE order_date between to_date ('2013/01/01', 'yyyy/mm/dd') AND to_date ('2013/12/31', 'yyyy/mm/dd');  SELECT * FROM orders WHERE order_date >= to_date('2013/01/01', 'yyyy/mm/dd') AND order_date <= to_date('2013/12/31','yyyy/mm/dd');