Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select record for every month
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Select record for every month
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Desktop
Divers
Thread ID:
01613120
Message ID:
01613120
Vues:
60
Hi all, is there a way to select records from two tables where the right hand side table may or may not have a matching record ? What I'm trying to do is produce a yearly report of sales per month per salesperson and if there are no entries for a given month I still want a record for the salesperson but showing a zero amount. I've looked at various *solutions* on the web but they all produce a null set which is not what I want. Null values for the sales is acceptable but I always want the salesperson name returned
// Table 1 ( Salesperson )
Salesperson
Pete
Paul
Mary

// Table2 ( Sales )
Salesperson.   Sale date.               SaleAmount
Pete.                  01/01/2015.          1000
Pete.                  01/01/2015.           2000

I would like the report to show

Salesperson.  Month.   Sumofmonthsales
Pete                  Jan.        3000
Pete.                  Feb.        0
etc... all through to December, and ditto for the rest of the salespersons. Hope this makes sense ( sorry about the formatting )
Regards,
Peter J. Kane



Pete
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform