Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Counting Question

Author  Topic 

tarheels4025
Starting Member

2 Posts

Posted - 2005-06-06 : 10:31:48
Below is a query I am working on. I am trying to make 3 count cases. The first one just counts all transactions. The second one counts only debit transactions that aren't approved.

For the third count case (one with *) I am trying to find out how many times a customer tries the same card on the same day. Is there any way to count this? A card is id_code_1 and days are by settlement_batch_number. For example if an id_code_1 shows up 3 times on a specific settlement_batch_number then it would show 3 as the count plus all the other id_code_1 that show up more time than once. IS there anyway to show the id_code_1 and how many times? If not just a total. Thanks for any help.


Use Winpayment
GO

SELECT S.card_acceptor_identification STORE,
COUNT (M.message_type) TOTAL_#_TRANS,
COUNT(CASE WHEN id_code_1 = 'DB' and response_code <> '00' THEN 1 END) DEBIT_DECLINED,
*COUNT(CASE WHEN THEN 1 END)
FROM Store S
Left Join financial_message M
On M.card_acceptor_identification = S.card_acceptor_identification
And (settlement_batch_number >= '880')

GROUP BY S.card_acceptor_identification

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-06-06 : 11:18:18
provide table structure with Create table statements
sample data with Insert into statements
and desired results based on your sample data.

that way you'll get the answer quickest.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-06 : 11:33:29
Follow the directions in the link below


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

tarheels4025
Starting Member

2 Posts

Posted - 2005-06-06 : 11:38:27
My bad sorry the card number in the database is id_number_1 not id_code_1. Would you have any ideas without me posting all of that info. It is a pretty big database. Thank you
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-06 : 11:44:50
It just has to be a sample...like I express in the link below.



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -