Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Do An IIF()...
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01115062
Message ID:
01116056
Vues:
16
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?
>>>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform