- Mar 1, 2000
- 30,890
- 5,001
- 126
I have the following QUERY:
with a table structure like:
What I really want to do though is get a COUNT of each time a SMINI or SCALLIPA occurs per given day per FILENO. Does that make sense?
So if, on FILENO 130645, on 4/28/2011 There are two rows, one with SMINI and one with SCALLIPA, that would not count as 2, it would count as 1.
I realize I am going about this fundamentally wrong right now, as I'm getting the number of CALLIPAs and SMINIs individually for each... my brain is stuck though and I can't get into the right train of thought.
Code:
SELECT
COUNT(CASE WHEN CODE = 'SMINI' THEN FILENO END) AS SMINI,
COUNT(CASE WHEN CODE = 'SCALLIPA' THEN FILENO END) AS SCALLIPA,
COUNT(*) AS [TOTAL CONTACTS]
FROM dbo.ACTIVE
WHERE (dbo.ACTIVE.CODE IN ('SMINI', 'SCALLIPA'))
with a table structure like:
Code:
P_id FILENO TRANS_DATE User Initials TRANS_TIME CODE Note Record Number
1 130645 4/28/2011 EEB 1899-12-30 15:04:02.000 EEB 15:04 MANUALLY UPDATED BAL ON TRIP SITE 42224947
What I really want to do though is get a COUNT of each time a SMINI or SCALLIPA occurs per given day per FILENO. Does that make sense?
So if, on FILENO 130645, on 4/28/2011 There are two rows, one with SMINI and one with SCALLIPA, that would not count as 2, it would count as 1.
I realize I am going about this fundamentally wrong right now, as I'm getting the number of CALLIPAs and SMINIs individually for each... my brain is stuck though and I can't get into the right train of thought.
