MS SQL Self Join | SQL Self Join | SQL Group by in Hindi



MS SQL Self Join | SQL Self Join | SQL Group by in Hindi

MS SQL Self Join | SQL Self Join | SQL Group by in Hindi

In this Video you will learn how to use MS SQL Self Join, with Aggregate function, group by, with Case Study.

below is Quarry for your reference

–Requirement
— Manager Name, Manager Gender, Leader Count, Sales in Million
— Profit in Million, Profit per Lead
select h.Manager_Name, H2.Gender, SUM( S.Lead) as ‘lead Count’,
Sum(CAST( S.Sales_Amount as bigint))/1000000 as ‘Sales in Million’,
Sum(Cast(S.Profit as bigint))/1000000 as ‘Profit in Million’,
Sum(Cast(S.Profit as bigint))/SUM( S.Lead) as ‘Proft per Lead’

from [Sale Call Report] S
Join [Head Count] H on S.Employees_ID = H.Employees_ID
Join [Head Count] H2 on h.Manager_Employee_ID = H2.Employees_ID
Group by h.Manager_Name, H2.Gender

#sql #sqlserver #groupby #selfjoin #Sql_Self_Join #mysql #mssql #dok_academy