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.
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 WinpaymentGOSELECT 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 statementssample data with Insert into statementsand 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 |
|
|
X002548
Not Just a Number
15586 Posts |
|
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 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|