|
-
December 5th, 2004, 03:44 PM
#1
How to create SQL-Statement for this
Hello, I have a problem to build a SQL for this tables created with Access:
Table1:
No|ProductID|Count
1|10|4
2|10|4
3|10|4
4|11|24
Table2:
No|ClientNo
1|100
2|100
3|101
I have to know how much Products with the No. 10 have been bought from different clients.
The solution should look like this:
ProductID|ProductNo|DiffClients
10|12|2
I am trying since days and I don't know how to find a solution.
I have tried s.th. like this:
select Table1.ProductID,sum(Table1.count),count(Table2.ClientNo) from Table1,Table2 where Table1.No = Table2.No group by Table1.ProductID
With this statement I always get the DiffClients with the value 3, this i wrong in this case I have to get the value 2. When I add to group by: table2.ClientNo I get two rows with the same ProductID, this is also wrong I will get one row.
Can someone help me please?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|