Upload
nirmal-patra
View
218
Download
0
Embed Size (px)
Citation preview
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 1/35
FUNCTIONSFUNCTIONSFUNCTIONSFUNCTIONS
1Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 2/35
SQL FunctionSQL Function
FunctionFunction
FunctionFunctionPerforms actionPerforms action
InputInput OutputOutput
arg1arg1
arg2arg2
argarg nn ResultResultValueValue
2Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 3/35
FunctionFunction
SingleSingle--rowrow
functionfunction
MultipleMultiple--rowrow
functionfunction
3Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 4/35
Single Row FunctionsSingle Row Functions
�� Manipulate data itemsManipulate data items
��
Accept arguments and return one valueAccept arguments and return one value�� Act on each row returnedAct on each row returned
�� Return one result per row.Return one result per row.
�� May modify the data type.May modify the data type.
�� Can be nested.Can be nested.
4Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 5/35
SingleSingle--rowrow
FunctionsFunctions
Character Character
Single Row FunctionsSingle Row Functions
ConversionConversion DateDate
GeneralGeneral Number Number
5Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 6/35
Character FunctionsCharacter Functions
Character Character
FunctionFunction
Case ConversionCase Conversionfunctionfunction
Character ManipulationCharacter Manipulationfunctionfunction
LOWERLOWER
UPPERUPPER
INITCAPINITCAP
CONCAT CONCAT
SUBSTRSUBSTR
LENGTHLENGTH
INSTRINSTR
L L--PADPAD
RR--PADPAD
TRIMTRIM 6Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 7/35
Case Conversion functionCase Conversion function
FunctionFunction ResultResult
LOWER(µGOD Bless You¶)LOWER(µGOD Bless You¶) god bless yougod bless you
UPPER(µGOD Bless You¶)UPPER(µGOD Bless You¶) GOD BLESS YOUGOD BLESS YOU
INITCAP(µGOD Bless You¶)INITCAP(µGOD Bless You¶) God Bless YouGod Bless You
7Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 8/35
Sample Output:Sample Output:
EMPLOYEE DETAILSEMPLOYEE DETAILS----------------------------------------------------------------------------------------------------------------------------------------------
The job title for King is presidentThe job title for King is presidentThe job title for Blake is manager The job title for Blake is manager
The job title for Clark is manager The job title for Clark is manager
. . .. . .
14 rows selected.14 rows selected.
Example:Example:
SQL> SELECT µThe job title for ¶ || INITCAP (ename)||µ is ¶SQL> SELECT µThe job title for ¶ || INITCAP (ename)||µ is ¶|| LOWER(job) AS ³EMPLOYEE DETAILS´|| LOWER(job) AS ³EMPLOYEE DETAILS´
FROM emp;FROM emp;
8Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 9/35
Character Manipulation functionCharacter Manipulation function
FunctionFunction ResultResult
CONCAT(µGood¶,µmorning¶)CONCAT(µGood¶,µmorning¶) GoodmorningGoodmorning
SUBSTR(µKIIT¶,2,3)SUBSTR(µKIIT¶,2,3) IITIIT
LENGTH(µUTPAL¶)LENGTH(µUTPAL¶) 55
INSTR(µUtpal¶, ¶a¶)INSTR(µUtpal¶, ¶a¶) 44
LPAD(sal,10,¶x¶)LPAD(sal,10,¶x¶) xxxxxx5000xxxxxx5000
TRIM(µK¶ FROM µKIIT¶)TRIM(µK¶ FROM µKIIT¶) IITIIT
9Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 10/35
Sample Output:Sample Output:
ENAMEENAME CONCATCONCAT LENGTHLENGTH INSTRINSTR
---------------------------------- -------------------------------------------------------- -------------------------------- ------------------------------------MARTINMARTIN MARTINSALESMANMARTINSALESMAN 66 22
ALLENALLEN ALLENSALESMANALLENSALESMAN 55 11
TURNERTURNER TURNERSALESMANTURNERSALESMAN 66 00
WARDWARD WARDSALESMANWARDSALESMAN 44 22
Example:Example:
SQL> SELECT ename, CONCAT(ename,job)SQL> SELECT ename, CONCAT(ename,job)
CONCAT, LENGTH(ename) LENGTH,CONCAT, LENGTH(ename) LENGTH,INSTR(ename,¶A¶) INSTRINSTR(ename,¶A¶) INSTR
FROM empFROM emp
WHERE SUBSTR(job,1,5) = µSALES¶;WHERE SUBSTR(job,1,5) = µSALES¶;
10Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 11/35
Number FunctionsNumber Functions
FunctionFunction ResultResult
ROUNDROUND
ROUND(45.926,2)ROUND(45.926,2)
Rounds value toRounds value to
specified decimalspecified decimal
45.9345.93
TRUNCTRUNC
TRUNC(45.926,2)TRUNC(45.926,2)
Truncates value toTruncates value to
specified decimalspecified decimal
45.9245.92MODMOD
MOD(1600,300MOD(1600,300))
Returns remainder of Returns remainder of
divisiondivision
10010011Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 12/35
Sample Output:Sample Output:
ROUND(45.923 , 2)ROUND(45.923 , 2) ROUND(45.923 , 0) ROUND(45.923,ROUND(45.923 , 0) ROUND(45.923, --1)1)
------------------------------------------------------ ---------------------------------------------------- ----------------------------------------------------45.9245.92 4646 5050
Example:Example:
SQL> SELECT ROUND(45.923 , 2), ROUND(45.923 , 0) ,SQL> SELECT ROUND(45.923 , 2), ROUND(45.923 , 0) ,ROUND(45.923,ROUND(45.923, --1)1)
FROM DUAL;FROM DUAL;
12Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 13/35
Sample Output:Sample Output:
TRUNC(45.923 , 2)TRUNC(45.923 , 2) TRUNC(45.923 , 0) TRUNC(45.923,TRUNC(45.923 , 0) TRUNC(45.923, --1)1)
------------------------------------------------------ ---------------------------------------------------- ----------------------------------------------------45.9245.92 4545 4040
Example:Example:
SQL> SELECT TRUNC(45.923 , 2), TRUNC(45.923 , 0) ,SQL> SELECT TRUNC(45.923 , 2), TRUNC(45.923 , 0) ,TRUNC(45.923,TRUNC(45.923, --1)1)
FROM DUAL;FROM DUAL;
13Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 14/35
Using the MOD FunctionsUsing the MOD Functions
Sample Output:Sample Output:
ENAMEENAME SALSAL COMMCOMM MOD(SAL,COMM)MOD(SAL,COMM)
------------------------------------ ---------------------------------- ------------------------------------------ ----------------------------------------------------
MARTINMARTIN 12501250 14001400 12501250
ALLENALLEN 16001600 300300 100100TURNERTURNER 15001500 00 15001500
WARDWARD 12501250 500500 250250
Example:Example:
SQL> SELECT ename, sal, comm, MOD(sal, comm)SQL> SELECT ename, sal, comm, MOD(sal, comm)
FROM empFROM emp
WHERE job = µSALESMAN¶;WHERE job = µSALESMAN¶;
14Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 15/35
Working with DatesWorking with Dates
�� Oracle stores dates in an internal character Oracle stores dates in an internal character
format : century, year, month, day, hours,format : century, year, month, day, hours,
minutes, seconds.minutes, seconds.
�� The default date format is DDThe default date format is DD--MonMon--YY.YY.
�� SYSDATE is function returning date andSYSDATE is function returning date and
time. However when the function is executedtime. However when the function is executed
it only gives the date, to view the time part itit only gives the date, to view the time part it
needs to be converted to character.needs to be converted to character.
�� DUAL is a dummy table used to viewDUAL is a dummy table used to view
SYSDATE.SYSDATE. 15Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 16/35
DualDual
DUAL table is owned by SYS and can beDUAL table is owned by SYS and can beaccessed by all users. As SELECT andaccessed by all users. As SELECT and
FROM clause are mandatory and severalFROM clause are mandatory and several
calculations do not need to use actualcalculations do not need to use actual
tables.tables.
Example:Example:
SQL> SELECT sysdateSQL> SELECT sysdateFROM dual;FROM dual;
33 ±± SEPSEP -- 0101
16Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 17/35
Arithmetic with DatesArithmetic with Dates
�� Add or subtract a number to or from a dateAdd or subtract a number to or from a date
for a resultantfor a resultant datedate value.value.
�� Subtract two dates to find the number of Subtract two dates to find the number of
days between those days.days between those days.
�� Add hours to a date by dividing the number Add hours to a date by dividing the number
of hours by 24.of hours by 24.
17Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 18/35
OperationOperation ResultResult DescriptionDescription
Date + number Date + number DateDate Adds a number of Adds a number of
days to a datedays to a date
DateDate ±± number number DateDate Subtracts aSubtracts a
number of daysnumber of days
from a datefrom a date
DateDate ±± datedate Number of Number of daysdays
Subtracts one dateSubtracts one datefrom another from another
Date +Date +
number/24number/24
DateDate Adds a number of Adds a number of
hours to a datehours to a date
Arithmetic with DatesArithmetic with Dates
18Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 19/35
Using Arithmetic operators with DatesUsing Arithmetic operators with Dates
Sample Output:Sample Output:
ENAMEENAME WEEKSWEEKS
------------------------ ----------------------------------------------
KINGKING 830.93709830.93709
CLARKCLARK 853.93709853.93709
MILLERMILLER 321.36566321.36566
Example:Example:SQL> SELECTSQL> SELECT last_namelast_name,(SYSDATE,(SYSDATE ±± hire_datehire_date) / 7 WEEKS) / 7 WEEKS
FROM employeesFROM employees
WHEREWHERE department_iddepartment_id = 90= 90;;
19Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 20/35
Date functionsDate functions
FunctionFunction DescriptionDescription
MONTHS_BETWEENMONTHS_BETWEENNumber Number of of monthsmonths
betweenbetween twotwo datesdates
ADD_MONTHSADD_MONTHSAddAdd calendar calendar monthsmonths
toto datedate
NEXT_DAYNEXT_DAYNextNext dayday of of thethe datedate
specifiedspecified
LAST_DAYLAST_DAY LastLast dayday of of thethe monthmonth
ROUNDROUND RoundRound datedate
TRUNCTRUNC TruncateTruncate DateDate20Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 21/35
�� MONTHS_BETWEEN(¶01MONTHS_BETWEEN(¶01--SEPSEP--95¶,¶1195¶,¶11--JANJAN--94¶)94¶)
19.677419419.6774194
�� ADD_MONTHS(¶11ADD_MONTHS(¶11--JANJAN--94¶,6)94¶,6)
¶11¶11--JULJUL--94¶94¶
�� NEXT_DAY(¶01NEXT_DAY(¶01--SEPSEP--95¶,¶FRIDAY¶)95¶,¶FRIDAY¶)
µ08µ08--SEPSEP--95¶95¶
�� LAST_DAY(¶01LAST_DAY(¶01--SEPSEP--95¶)95¶)
¶30¶30--SEPSEP--95¶95¶
Using Date FormatsUsing Date Formats
21Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 22/35
Sample Output:Sample Output:
EMPNO HIREDATE TENURE REVIEW NEXT_DAY( LAST_DAY(EMPNO HIREDATE TENURE REVIEW NEXT_DAY( LAST_DAY(
---------------------- ---------------------------------- -------------------------------- ---------------------- ------------------------------------ ----------------------------------
78397839 1717--NOVNOV--81 192.24794 1781 192.24794 17--MAYMAY--82 2082 20--NOVNOV--81 3081 30--NOVNOV--818176987698 0101--MAYMAY--81 198.76407 0181 198.76407 01--NOVNOV--81 0881 08--MAYMAY--81 3181 31--MAYMAY--8181
««.««.
11 Rows selected11 Rows selected
Example:Example:
SQL> SELECT empno, hiredate,SQL> SELECT empno, hiredate,
MONTHS_BETWEEN(TO_DATE(SYSDATE,¶DDMONTHS_BETWEEN(TO_DATE(SYSDATE,¶DD--MONMON--YY¶),hiredate)YY¶),hiredate)
TENURE,TENURE,
ADD_MONTHS(hiredate, 6) REVIEW,ADD_MONTHS(hiredate, 6) REVIEW,NEXT_DAY(hiredate, µFRIDAY¶),NEXT_DAY(hiredate, µFRIDAY¶),
LAST_DAY(hiredate)LAST_DAY(hiredate)
FROM empFROM emp
WHERE MONTHS_BETWEEN(TO_DATE(SYSDATE,¶DDWHERE MONTHS_BETWEEN(TO_DATE(SYSDATE,¶DD--MONMON--YY¶),YY¶),
,hiredate) < 200;,hiredate) < 200;
22Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 23/35
�� ROUND(¶25ROUND(¶25--JULJUL--95¶,¶MONTH¶)95¶,¶MONTH¶) 0101--AUGAUG--9595
Using Date FunctionsUsing Date Functions
�� ROUND(¶25ROUND(¶25--JULJUL--95¶,¶YEAR¶)95¶,¶YEAR¶) 0101--JANJAN--9696
�� TRUNC(¶25TRUNC(¶25--JULJUL--95¶,¶MONTH¶)95¶,¶MONTH¶) 0101--JULJUL--9595
�� TRUNC(¶25TRUNC(¶25--JULJUL--95¶,¶YEAR¶)95¶,¶YEAR¶) 0101--JANJAN--9595
23Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 24/35
Sample Output:Sample Output:
EMPNO HIREDATE ROUND(HIR TRUNC(HIREMPNO HIREDATE ROUND(HIR TRUNC(HIR
---------------------- ---------------------------------- -------------------------------------- ------------------------------------
7788 097788 09--DECDEC--82 0182 01--DECDEC--82 0182 01--DECDEC--8282
7934 237934 23--JANJAN--82 0182 01--FEBFEB--82 0182 01--JANJAN--8282
««.««.
11 Rows selected11 Rows selected
Example:Example:
SQL> SELECTSQL> SELECT empnoempno,, hiredatehiredate,,
ROUND(ROUND(hiredate,¶MONTHhiredate,¶MONTH¶) , TRUNC(¶) , TRUNC(hiredate,¶MONTHhiredate,¶MONTH¶)¶)
FROMFROM empempWHEREWHERE hiredatehiredate like µ%1982¶;like µ%1982¶;
24Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 25/35
Conversion FunctionsConversion Functions
Data typeData type
ConversionConversion
Implicit data typeImplicit data type
conversionconversion
Explicit data typeExplicit data type
conversionconversion
25Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 26/35
Implicit data type conversionImplicit data type conversion
For assignments Oracle Server can automatically convertFor assignments Oracle Server can automatically convert
the following:the following:
FromFrom ToTo
VARCHAR2 or CHARVARCHAR2 or CHAR NUMBERNUMBER
VARCHAR2 or CHARVARCHAR2 or CHAR DATEDATE
NUMBERNUMBER VARCHAR2VARCHAR2
DATEDATE VARCHAR2VARCHAR2
For expression Oracle Server can automatically convertFor expression Oracle Server can automatically convert
the following:the following:
FromFrom ToTo
VARCHAR2 or CHARVARCHAR2 or CHAR NUMBERNUMBER
VARCHAR2 or CHARVARCHAR2 or CHAR DATEDATE26Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 27/35
Explicit data type conversionExplicit data type conversion
TO_NUMBERTO_NUMBER TO_DATETO_DATE
NUMBERNUMBER CHARACTERCHARACTER DATEDATE
TO_CHARTO_CHARTO_CHARTO_CHAR
27Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 28/35
TO_CHAR Function with datesTO_CHAR Function with dates
TO_CHAR(date, µfmt¶)TO_CHAR(date, µfmt¶)TheThe formatformat modelmodel ::
��MustMust bebe enclosedenclosed inin singlesingle quotationquotation marksmarks andand isis casecase
sensitivesensitive..�� CanCan includeinclude anyany validvalid datedate formatformat elementelement..
�� HasHas anan fmfm (fill (fill mode)mode) elementelement toto removeremove paddedpadded blanksblanks or or
suppresssuppress leadingleading zeroszeros..
�� IsIs separatedseparated fromfrom thethe datedate valuevalue byby aa commacomma..
Example:Example:
SQL>SQL> SELECT empno, TO_CHAR(hiredate, µfmMM/YY¶) Month_HiredSELECT empno, TO_CHAR(hiredate, µfmMM/YY¶) Month_Hired
FROM empFROM emp
WHERE ename = µBLAKE¶ ;WHERE ename = µBLAKE¶ ; 28Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 29/35
Element of date format modelElement of date format model
YYYYYYYY Full year in numbersFull year in numbers
YEARYEAR Year spelled outYear spelled out
MMMM TwoTwo--digit value for monthdigit value for monthMONTHMONTH Full name of the monthFull name of the month
DYDY ThreeThree--letter abbreviation of the day of letter abbreviation of the day of
the weekthe weekDAYDAY Full name of the dayFull name of the day
29Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 30/35
ElementElement DescriptionDescription
SCC or CCSCC or CC Century, S prefixes BC date withCentury, S prefixes BC date with --
Years in dates YYYY or Years in dates YYYY or SYYYYSYYYY
Year, S prefixes BC date withYear, S prefixes BC date with --
YYY or YY or YYYY or YY or Y Last 3 / 2 / 1 digit of the year Last 3 / 2 / 1 digit of the year
Y,YYYY,YYY Year with comma in this positionYear with comma in this position
IYYY,IYY,IY,IIYYY,IYY,IY,I 4/3/2/1 digit year based on the ISO4/3/2/1 digit year based on the ISOstandardstandard
SYEAR or YEARSYEAR or YEAR Year spelled out S prefixes BCYear spelled out S prefixes BC
date withdate with --
BC or ADBC or AD BC/AD indicator BC/AD indicator B.C or A.DB.C or A.D BC/AD Indicator with periodsBC/AD Indicator with periods
QQ quarter of the year quarter of the year
MMMM Month, two digit valueMonth, two digit value
30Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 31/35
ElementElement DescriptionDescription
MONTHMONTH Name of the month padded withName of the month padded with
blanks to length of nineblanks to length of ninecharacterscharacters
MONMON Name of the month, three letter Name of the month, three letter
abbreviation.abbreviation.
RMRM Roman numeral monthRoman numeral monthWW or WWW or W Week of year or monthWeek of year or month
DDD or DD or DDDD or DD or D Day of year / month/ weekDay of year / month/ week
DAYDAY Name of the day padded withName of the day padded with
blanks to length of nine character blanks to length of nine character
DYDY Name of the Day; three letter Name of the Day; three letter
abbreviationabbreviation
JJ Julian day; the number of daysJulian day; the number of days
since 31 December 4731 BCsince 31 December 4731 BC 31Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 32/35
ElementElement DescriptionDescription
AM or PMAM or PM Meridian indicator Meridian indicator
A.M or P.MA.M or P.M Meridian indicator with periodsMeridian indicator with periods
HH / HH12 / HH24HH / HH12 / HH24 Hour of day or hour (1Hour of day or hour (1--12) or hour 12) or hour
(0(0--23)23)
MIMI Minute ( 0Minute ( 0 ±±59 )59 )
SSSS Second ( 0Second ( 0 ±± 59 )59 )
SSSSSSSSSS Seconds past midnight ( 0Seconds past midnight ( 0 ±±
86399)86399)
THTH Ordinal Number ( DDTH for 4Ordinal Number ( DDTH for 4THTH
))SPSP Spelled out number (DDSP for Spelled out number (DDSP for
FOUR)FOUR)
SPTH or THSPSPTH or THSP SpelledSpelled--out ordinal number out ordinal number
(DDSPTH(DDSPTH ±± FOURTH)FOURTH) 32Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 33/35
Using TO_CHAR Function with datesUsing TO_CHAR Function with dates
Example:Example:SQL>SQL> SELECTSELECT enameename,,
TO_CHAR(TO_CHAR(hiredate,¶fmDdspthhiredate,¶fmDdspth ³of´ Month YYYY³of´ Month YYYY
fmHHfmHH : MI : SS AM¶) HIREDATE: MI : SS AM¶) HIREDATE
FROMFROM empemp;;
Sample Output:Sample Output:
ENAMEENAME HIREDATEHIREDATE
---------------------- ------------------------------------------------------------------------
KINGKING Seventeenth of November 1981 12:00:00 AMSeventeenth of November 1981 12:00:00 AM
BLAKEBLAKE First of May 1981 12 : 00 :00 AMFirst of May 1981 12 : 00 :00 AM
««.««.
14 Rows selected14 Rows selected 33Utpal/SCA/SQL-3
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 34/35
Utpal/SCA/SQL-3 34
1. Display the last name, salary and commission for all employees
whose commission amount is 20%.
2. Display the employees number, last name, salary and salary
increase by 50% and expressed as a whole number.
3. W.A.Q that display the employees last name with the first letter
capitalized and all other letters in lower case and the length of the
name for all employees whose name starts with J , A or M. Give
each column an appropriate label. Sort the result by theemployees last name.
4. For each employee, display the employees last name, and
calculate the number of months between today and the date of
the employees was hired. Label the column MONTHS-WORKED.
Order your results by the number of months employed. Round thenumber of months up to the closest whole number.
8/7/2019 quary4
http://slidepdf.com/reader/full/quary4 35/35
Utpal/SCA/SQL-3 35
Create a query to display the last name and salary for all employees
.Format the salary to be 15 characters long. Left padded with $. Label
the column SALARY.
Create a query that display the employee last name and indicatesthe amounts of their annual salary to be 8 characters with (*). Sort
the data in descending order of salary. Label the column Employee
_And _Their_ Salary.
C
reate a query to display First_name, Hire date, One yearcompletion date and salary of all employees in ascending order
according to hire date.
Create a query to display the Last name, salary of employee and
increased salary by 20% in department 20, 80 and 50 .
Write a query to display the Last name, First name , total length of their complete name, designation ,salary of each employee in
department 40 and 50 . sort the records as per their length of name.
Write a query to display the Location ID , city, state_ province and
city code where city code is the first four character of city, in
descending order of city code for country id US,UK,CA,JP and IN.