Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Proper SQL Query Statement
Message
De
14/02/2002 14:34:55
Jason Dalio
Northern Interior Regional Health Board
Prince George, Colombie Britannique, Canada
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00620242
Message ID:
00620269
Vues:
16
I think you need something like the following:
SELECT Invoice.Invoice_ID, Invoice.Invoice_Contact, Count(InvoiceLineItems.InvoiceLineItemsID) AS CountOfInvoiceLineItemsID
FROM (Invoice INNER JOIN InvoiceLineItems ON Invoice.Invoice_ID = InvoiceLineItems.InvoiceID) LEFT JOIN InvoicePayments ON Invoice.Invoice_ID = InvoicePayments.InvoiceID
GROUP BY Invoice.Invoice_ID, Invoice.Invoice_Contact, InvoicePayments.InvoicePaymentsID
HAVING (((Count(InvoiceLineItems.InvoiceLineItemsID))>=3) AND ((InvoicePayments.InvoicePaymentsID) Is Null));
The Is Null forces the return of only invoices where there is no payment records beacuse of the outer join.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform