|
Posted by Hugo Kornelis on 11/02/05 00:20
On 1 Nov 2005 13:38:22 -0500, triciam wrote:
>I am using this query but its not working, please help
>
>select customers.customerid, customers.country,
>orders.orderid, orders.orderdate, orderdetails. sum(unitprice) as
>TotalSales
>from customers, orders, orderdetails
>left join orders on customers.customerid = orders.customerid
>where orderdate > 11/1/4
>and country <> USA
>and unitprice > 0
>and orderid > 346544
>group by orderid
>order by orderid
>
>This is the error message that Im getting:
>ables or functions orders and orders have the same exposed names.
>Use correlation names to distinguish them.
> Im not sure how to make this work......... Thank You Tricia :)
Hi Tricia,
I'll have to make some pretty big assumptions in my answer. Next time
you post, you might want to include CREATE TABLE statements to show us
how the tables look, INSERT statements with sample data and the expected
results. See www.aspfaq.com/5006 for more details.
For your query, you might try the following:
SELECT c.customerid, c.country, o.orderid, o.orderdate,
SUM(od.unitprice) AS TotalSales
FROM customers AS c
INNER JOIN orders AS o
ON o.customerid = c.customerid
INNER JOIN orderdetails AS od
ON od.orderid - o.orderid
WHERE o.orderdate > '11/1/4' -- but see below
AND c.country <> 'USA'
AND od.unitproce > 0
AND o.orderid > 346544
GROUP BY o.orderid, o.orderdate, c.customerid, c.country
ORDER BY o.orderid
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Navigation:
[Reply to this message]
|