0

Hello guys i am little bit confuse here with the code
can any one help me out ..
i want max customer paid in shopping and their name
i dont know that i am using right way or not but guide me here

Select sum(od.unitprice * od.quantity) as Amount,
        (Select ContactName from Customers where customerId in (o.customerid)) as CustomerName  from [Order Details] as od
        inner join orders as o on o.orderid = od.orderid
        inner join customers as c on o.customerid = c.customerid
group by o.customerid

here if i use

Max(sum(od.unitprice * od.quantity)) as Amount

i get error can you please correct the code... i want the customer name
who have paid amount very much.

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by shayankhan
0
Select sum(od.unitprice * od.quantity) as Amount,
ContactName  as customername  from [Order Details] as od
        inner join orders as o on o.orderid = od.orderid
        inner join customers as c on o.customerid = c.customerid
group by o.customerid,ContactName  
order by amount desc limit 1
0

I am getting error

Incorrect syntax near 'LIMIT'.

i am using sql 2008

0

well i used TOP 1 before the sum() functions and now its working ..
thanks for helping me out.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.