create table #temp
(
Id int,
Name varchar(50),
Salary decimal(18,2)
)
insert into #temp(Id,Name,Salary) values(1,'A',6000),(2,'B',10000),(3,'C',6000),(4,'D',1000),(5,'A',1000),(6,'B',1000)
create table #temp1
(
Id int,
Inc decimal(18,2)
)
insert into #temp1(Id,Inc) values(1,200),(2,500),(3,300),(4,3000)
Write SQL query to update salary with add on Inc (Incentive) on table1 from tabl2 on behalf of Id column-
update #temp
set Salary = Salary + isnull(Inc,0)
from #temp1 where #temp.Id=#temp1.Id
Write SQL query to show unique name like 'A' and sum of all salaries of 'A'-
select Name, SUM(Salary) as TotalSalary from #temp t group by t.Name
(
Id int,
Name varchar(50),
Salary decimal(18,2)
)
insert into #temp(Id,Name,Salary) values(1,'A',6000),(2,'B',10000),(3,'C',6000),(4,'D',1000),(5,'A',1000),(6,'B',1000)
create table #temp1
(
Id int,
Inc decimal(18,2)
)
insert into #temp1(Id,Inc) values(1,200),(2,500),(3,300),(4,3000)
Write SQL query to update salary with add on Inc (Incentive) on table1 from tabl2 on behalf of Id column-
update #temp
set Salary = Salary + isnull(Inc,0)
from #temp1 where #temp.Id=#temp1.Id
Write SQL query to show unique name like 'A' and sum of all salaries of 'A'-
select Name, SUM(Salary) as TotalSalary from #temp t group by t.Name
No comments:
Post a Comment