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!

hi- I am trying an SQL but could

Status
Not open for further replies.

justsql

Programmer
Jun 20, 2002
7
US
hi-

I am trying an SQL but couldn't achieve with a query, any help will be highly appreciated.

There are two tables say Table A and B
A(col1,
Qual,
ID,
ref)

B(col1,(FK to Col1 on A)
type of transaction,
Date of transaction,
Status of transaction,
date of acknowledgement)

Now I have to get the result with a query in this format

qual ID Type Date ToTal Total
of trans of trans Sent Acknowledged

Any help will be highly appreciated.

Thanks
 
Code:
SELECT A.qual,
       A.ID,
       B.TypeTrans,
       B.DateTrans,
       COUNT(B.*) AS "Total Sent",
       COUNT(B.DateAcknowledged) AS "Total Acknowldgd"

FROM A
JOIN B ON A.Col1 = B.Col1
GROUP BY A.qual,
       A.ID,
       B.Type,
       B.DateTrans
 
Thanks for the reply, I forgot to add one more condition. The acknowledged count should be only for the documents that are acknowledgemed say status is "01"...
 
Replace JOIN B ON A.Col1 = B.Col1 with

JOIN B ON A.Col1 = B.Col1 AND B.StatusTrans = '01'
 
Thanks rac2 again..

But that will return all the rows that are acknowledged. I need the count for all under documents sent and count of those documents acknowledged under documents acknowledged.

 
Assuming that date of acknowledgement is null for documents that are sent but not acknowledged, the first query will give you the counts you need.

I don't know what a status code of 01 means and I don't know what your data looks like. I hope my suggestions help you solve your problem.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top