Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Question About Counts

Status
Not open for further replies.

monsjic

Programmer
Jan 23, 2002
23
US
Here is the question with the right information.
Sorry about the confusion.
I have data like below:

TABLE 1 TABLE 2
Cust #: Inv #: Cust #: Inv #:
A 1 A 1
A 1

I want to get a count of matches on Cust # and Inv #
SELECT Count('x') AS COUNT
FROM Table1 INNER JOIN Table2 ON (Table1.C# = Table2.I#) AND (Table1.C# = Table2.I#);

But I want it to return the answer of 1 for the above sample data. The SQL above returns the answer of 2.

Does anyone know how to get my desired results?

Thanks
 
i am not clear about ur join like
Table1.C# = Table2.I#

Any how it will be solved with this query.

SELECT Count(*) AS [Count]
FROM [SELECT Table2.C#, Table2.I#
FROM Table2
GROUP BY Table2.C#, Table2.I#]. AS table3 INNER JOIN Table1 ON (table3.I# = Table1.I#) AND (table3.C# = Table1.C#);

I will wait for the response of ur satisfaction

Razi Zaidi razizaidi@hotmail.com
 
DOH!
Once again I messed up my question.
PLEASE IGNORE THIS THREAD.
If you know how to delete you own threads, please let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top