Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Question = my employees on the base of money maximum which product was sold.With EmployeeID

Answer =

 EmployeeID  ProductID   Total
----------- ----------- ----------------------
1           38          23570,0749511719
2           38          25190,5999755859
3           38          25559,5
4           38          29432,9499511719
5           59          7584,5
6           59          6671,5
7           38          16695,3603515625
8           29          9244,82507324219
9           38          14624,25


(9 row(s) affected)

i tried but it's wrong

WRONG
SQL
select e.EmployeeID,Count(OD.ProductID),Sum(OD.UnitPrice*Quantity *(1-Discount)) as ToplamFiyat from Orders as o
inner join [Order Details] as OD on OD.OrderID=o.OrderID
inner join Employees as e on e.EmployeeID=o.EmployeeID
inner join Products as p on p.ProductID=OD.ProductID
group by e.EmployeeID
order by 1


WRONG
SQL
select  e.EmployeeID,OD.ProductID,Sum(OD.UnitPrice*Quantity *(1-Discount)) as ToplamFiyat from Orders as o
inner join [Order Details] as OD on OD.OrderID=o.OrderID
inner join Employees as e on e.EmployeeID=o.EmployeeID
inner join Products as p on p.ProductID=OD.ProductID
group by e.EmployeeID,OD.ProductID
order by 1


PLS HELP :)


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 31-Aug-13 3:36am
v2
Comments
coded007 25-Sep-13 1:43am    
Check with this

select O.EmployeeID,OD.ProductID,Sum(OD.UnitPrice*Quantity *(1-Discount)) as ToplamFiyat from Orders as o
inner join [Order Details] as OD on OD.OrderID=o.OrderID
inner join Products as p on p.ProductID=OD.ProductID
group by OD.ProductID,o.EmployeeID
order by OD.ProductID

1 solution

Check with this

SQL
select O.EmployeeID,OD.ProductID,Sum(OD.UnitPrice*Quantity *(1-Discount)) as ToplamFiyat from Orders as o
inner join [Order Details] as OD on OD.OrderID=o.OrderID
inner join Products as p on p.ProductID=OD.ProductID
group by OD.ProductID,o.EmployeeID
order by OD.ProductID
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900