Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Do An IIF()...
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01115062
Message ID:
01116057
Views:
14
Yes, here's the code:
SELECT rd.transaction_date,
       0 as batchid,
       tm.company_code as entityid,
       count(*) as totrecs,
       rdi.status,
       (CASE WHEN LEN(rdi.used_by)= 0 THEN NULL ELSE rdi.used_by END) AS used_by
FROM result_detail rd
JOIN telemrkt_company tm on rd.telemrkt_company = tm.id
LEFT OUTER JOIN result_detail_info rdi on rd.id = rdi.result_detail_id AND rdi.status IS NULL
GROUP BY rd.transaction_date, tm.company_code, rdi.status, rdi.used_by
ORDER BY company_code
>Did you remove
WHERE rdi.status IS NULL
>
>>Sergey, results unchanged.
>>
>>
>>>Try
>>>LEFT OUTER JOIN result_detail_info rdi on rd.id = rdi.result_detail_id
>>>  AND rdi.status IS NULL
>>>
>>>>Ok, now I'm really close to done here. 1 more question:
>>>>
>>>>There are 387 records in result_detail. Only 5 have a Used_By value in the joined table
>>>>result_detail_info.
>>>>
>>>>As it is now, I get back 1 record:
>>>>
>>>>transaction_date         batchid  entityid totrecs status used_by
>>>>------------------------------------------------------------------
>>>>2006-01-03 00:00:00.000  0	  WEST	   5	   NULL	  KMAROIS             	
>>>>
>>>>
>>>>What I am trying to get back is:
>>>>
>>>>transaction_date         batchid  entityid totrecs status used_by
>>>>------------------------------------------------------------------
>>>>2006-01-03 00:00:00.000  0	  WEST	   5	   NULL	  KMAROIS             	
>>>>2006-01-03 00:00:00.000  0	  WEST	   382	   NULL	  NULL
>>>>
>>>>
>>>>Here's the latest code:
>>>>
>>>>
>>>>SELECT rd.transaction_date,
>>>>       0 as batchid,
>>>>       tm.company_code as entityid,
>>>>       count(*) as totrecs,
>>>>       rdi.status,
>>>>       (CASE WHEN LEN(rdi.used_by)= 0 THEN NULL ELSE rdi.used_by END) AS used_by
>>>>FROM result_detail rd
>>>>JOIN telemrkt_company tm on rd.telemrkt_company = tm.id
>>>>LEFT OUTER JOIN result_detail_info rdi on rd.id = rdi.result_detail_id
>>>>WHERE rdi.status IS NULL
>>>>GROUP BY rd.transaction_date, tm.company_code, rdi.status, rdi.used_by
>>>>ORDER BY company_code
>>>>
>>>>
>>>>Why am I not seeing the remainder of unused records as a group?
>>>>
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform