This document contains SQL queries that summarize sales data from various tables, grouping and summing fields like SubTotal, tax amount (IGV), and total due, and ordering the results by customer name. It also includes queries to view the contents of relevant tables like SalesOrderHeader, Person, and SalesPerson for analysis.
This document contains SQL queries that summarize sales data from various tables, grouping and summing fields like SubTotal, tax amount (IGV), and total due, and ordering the results by customer name. It also includes queries to view the contents of relevant tables like SalesOrderHeader, Person, and SalesPerson for analysis.
This document contains SQL queries that summarize sales data from various tables, grouping and summing fields like SubTotal, tax amount (IGV), and total due, and ordering the results by customer name. It also includes queries to view the contents of relevant tables like SalesOrderHeader, Person, and SalesPerson for analysis.
sum (h.SubTotal) SubTotal, sum (h.taxamt) IGV, sum (h.TotalDue) total from sales.SalesOrderHeader h Inner Join sales.Customer c on h.CustomerID= c.CustomerID inner join sales.SalesPerson p on p.BusinessEntityID = h.SalesPersonID inner join person.Person x on x.BusinessEntityID = p.BusinessEntityID
Group By Rtrim(x.firstname) + ' '+ Rtrim (x.lastname)
Order By 1
select * from sales.SalesOrderHeader
select * from Person.Person select * from sales.SalesPerson