Download presentation

Presentation is loading. Please wait.

Published byJaeden Lisby Modified over 2 years ago

1
Operators: SQL supports various arithmetic, logical, character, and relational r operators. Arithmetic Operators: Arithmetic operators in SQL will return numeric values. OperatorsFunctionExample +AddUpdate set emp basic = basic + 500; -SubtractUpdate set emp basic = basic - 500; *MultiplyUpdate set emp basic = basic + basic * 5/100; /DivideUpdate set emp basic = basic + basic * 5/100;

2
Logical Operators: Logical operators in SQL will return either true or false value. OperatorsFunctionExample ANDCheck two conditions are true Select * from emp where basic >= 10000 AND basic <= 20000; ORCheck any of the two conditions are true Select * from emp where basic >= 10000 OR dept = ‘Sales’; NOTReversed the result of logical expression Select * from emp where NOT(basic >= 10000 OR dept = ‘Sales’);

3
Character Operators: Character operators are used to manipulate character strings. OperatorsFunctionExample ||Concatenates character strings Select ‘Name is ‘ || ename from emp; Output: Name is Kumar Name is Umar Name is Vino Name is Raj

4
Comparison Operators: Comparison operators in SQL will compare two quantity OperatorsMeaning/Function =Equal to !=, <>Not equal to >Greater than >=Greater than or equal to

5
OperatorsMeaning/Function INEqual to any member of a given set NOT INNot equal to any member of a given set BETWEENIn between two values NOT BETWEENNot in between two values EXISTSTrue if sub query returns at least one row ANYCompares a value to each list of value (must be prefaced with =,!=,,>=) ALLCompares a value to every list of value (must be prefaced with =,!=,,>=)

6
Example: 1)To find the employees who are clerks, manager or assistant manager. select * from emp where post in (‘Clerk’,’Manager’,’Asst.Manager’); or select * from emp where post = ‘Clerk’ or post = ‘Manager’ or post = ‘Asst.Manager ’ 2) To find the employees who are not clerks, manager or assistant manager. select * from emp where post not in (‘Clerk’,’Manager’,’Asst.Manager’); 3) To find the employees whose salary lies in between 10000 and 20000 select * from emp where basic between 10000 and 20000; or Select * from emp where basic >= 10000 AND basic <= 20000; 4) To find the employees whose salary not lies in between 10000 and 20000 select * from emp where basic not between 10000 and 20000;

7
LIKE Operator: (Matching a character pattern) When one does not know the exact value for the search conditions and wishes to use a replaceable parameter a LIKE operator can be used. The replaceable parameters used are shown bellow. SymbolRepresents %Any sequence or more characters _Any single character Example: 1) To list employees whose names begin with ‘U’ select * from emp where ename like ‘U%’ ; 2) To list employees who name start with ‘Kum’ and ends with ‘r’; select * from emp where ename like ‘Kum_r’;

8
Aggregate Functions (Group Functions) Aggregate functions are statistical functions such as MIN,MAX,SUM,AVG,COUNT,STDDEV,VARIANCE and etc. Aggregate functions return results based on groups of rows rather than on single rows. Aggregate function accepts two options, DISTINCT – It causes a group function to consider only distinct values of the argument expression. exp : the DISTINCT average of 1,1,1, 3 is 2 ALL – It causes a group function to consider all values including all duplicates. exp : the ALL average of 1,1,1, 3 is 1.5 Note: if neither option is specified, the default is ALL 1. AVG - returns average value of n. Syntax: AVG( [ DISDINCT | ALL ] n) Example: SELECT AVG (basic) FROM emp; Output: AVG(basic) -------------- 5000

9
EnoEnameDeptpostbasic 111KumarSalesManager6000 222UmarPurchaseAccountant5000 333VinoSalesClerk3000 444RajMarketingManager6000

10
2. MAX - returns maximum value of n. Syntax: MAX( [ DISDINCT | ALL ] n) Example: SELECT MAX (basic) FROM emp; Output: MAX(basic) -------------- 6000 3. MIN - returns minimum value of n. Syntax: MIN( [ DISDINCT | ALL ] n) Example: SELECT MIN (basic) FROM emp; Output: MIN(basic) -------------- 3000

11
4.SUM - returns the sum of values of n. Syntax: SUM( [ DISDINCT | ALL ] n) Example: SELECT SUM (basic) FROM emp; Output: SUM(basic) -------------- 20000

12
5.COUNT - returns the number of rows in a query. If we use asterisk(*) this function returns all rows including duplicates and nulls. Syntax: COUNT(* | [ DISTINCT | ALL ] n ) Example: SELECT COUNT (*) FROM emp; Output: COUNT(*) -------------- 4 Example: SELECT COUNT (DISTINCT basic) FROM emp; Output: COUNT(basic) -------------- 3 6.STDDEV - returns standard deviation of n Syntax: STDDEV ( [ DISTINCT | ALL] n) 7.VARIANCE - returns variance of n Syntax: VARIANCE ( [ DISTINCT | ALL ] n)

Similar presentations

OK

Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.

Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Animated ppt on magnetism and electricity Ppt on effective body language Ppt on network file system Ppt on electric potential energy Ppt on first conditional form Download ppt on chemical bonding and molecular structure Ppt on overhead service connection Ppt on alpha and beta testing Ppt on new technology in mobiles Ppt on shell structures analysis