Wednesday, 6 December 2017

Add two number Through Select Case, Min Salary and Having Clouse


*Add two number Through Select Case
select 2+4 as 'Sum'

*Agrigate Function
select avg(salary) "Average" from employee

*Min Salary
select min(salary) 'Salary' from employee

*2nd Min Salary
select min(salary) "Salary" from employee where salary > (select min(salary) from employee)

*4th Min Salary
select min(salary) "Salary" from employee where salary > (select min(salary) from employee where salary > (select min(salary) from employee where salary > (select min(salary) from employee)))

*5th Min Salary
select min(salary) "Salary" from employee where salary > (select min(salary) from employee where salary > (select min(salary) from employee where salary > (select min(salary) from employee where salary > (select min(salary) from employee))))

select count(deptid) "DeptID" from employee

select count(deptname) 'DeptName' from employee

select count(*) "EmpId" from employee

select sum(salary) "Salary" from employee

select power(3,2) as "power"

select abs(-15) as "Absolute"

select round(15.19,1) as "Round"

select round(15.19,2) as 'Round'

select sqrt(125) as "Squire"

select sqrt(25) as 'SquireRoot'

select exp(5) as "Exponential"

select exp(4) as "Exponential"

select floor(24.8) as "Floor1",floor(13.15) as "Floor2"

select lower('PRADEEP KUMAR') as "Name"

select upper('pradeep kumar') as "Name"

select ascii('a') as "ASCII VALUE1", ascii('A') as 'ASCII VALUE2'

select len('munaa k') as "Length"

select ltrim('NISHA') as "Ltrim"

//select ltrim('NISHA','N') as "Ltrim"

//select rtrim('SUSHILA','A') as "RTRIM"

select user as "USER"

select getdate() as "Date"

select CURRENT_TIMESTAMP as "DateTime"

SELECT {fn NOW()}

select GETUTCDATE( )

select deptname as "DeptName" from employee group by deptname

select deptid from employee group by deptid

select distinct(deptid) from employee

*Having Function
select count(deptid) "DeptIdCount" from employee group by deptid having count(deptid) < 10

select count(deptid) "DeptIdCount" from employee group by deptid having deptid <=10

select deptid from employee group by deptid having deptid >=10

select count(deptid) "CountDeptId" from employee group by deptid having deptid >10

select deptid as "DeptID" from employee group by deptid having deptid > 10

select count(deptname) "DEPTNAME" from employee group by deptname having deptname='MCA'

select count(deptname) "DEPTNAME" from employee group by deptname having deptname='MBA'

select count(deptname) "DEPTNAME" from employee group by deptname having deptname='B.Tech'

select count(deptname) "DEPTNAME" from employee group by deptname having deptname='M.Tech'

select count(deptname) "DEPTNAME" from employee group by deptname having deptname=''

0 comments

Post a Comment