Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting stats on repartition
Message
De
11/01/2011 17:46:18
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01495766
Message ID:
01495789
Vues:
29
>If you need a report with all statuses for each destination, then first you need to do a cross join between statuses and destinations and the LEFT JOIN with the rest of your query (derived table).
>
>If you post relevant DDL and some insert statements and desired output, I'll post a query for you.

Right now, my SQL is like this:
SELECT ExportDestination.Title,ExportStatus.Title_E,COALESCE(Temp.CountRecord,0) AS CountRecord
FROM
(SELECT Export.NoExportStatus,Export.NoExportDestination,COUNT(*) AS CountRecord
 FROM Export (NOLOCK)
 GROUP BY Export.NoExportStatus,Export.NoExportDestination) Temp
INNER JOIN ExportDestination ON Temp.NoExportDestination=ExportDestination.Numero
RIGHT JOIN ExportStatus ON Temp.NoExportStatus=ExportStatus.Numero
It gets a result like this:
Title                 Title_E        CountRecord
NULL                  Pending               0
First destination     Completed         13209
Second destination    Completed         13209
NULL                  In progress           0
NULL                  Calculated            0
NULL                  Retry                 0
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform