Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need product 1

Status
Not open for further replies.

Johnny42

Technical User
Jul 13, 2004
127
CA
Code:
SELECT     TOP 100 PERCENT dbo.tblClient.NomCompagnie, dbo.tblCommande.POClient, dbo.tblStatut.StatutCommande, dbo.tblCommande.DateCreation, 
                      dbo.tblCommandeProduit.Discount, dbo.tblCommandeProduit.NomProduit, dbo.tblCommande.PO, dbo.tblCommandeProduit.Qte, 
                      dbo.tblCommandeProduit.Prix, dbo.tblCommande.ActivationDate
FROM         dbo.tblCommande INNER JOIN
                      dbo.tblCommandeProduit ON dbo.tblCommande.refCommande = dbo.tblCommandeProduit.refCommande INNER JOIN
                      dbo.tblClient ON dbo.tblCommande.refClient = dbo.tblClient.refClient INNER JOIN
                      dbo.tblStatut ON dbo.tblCommande.Statut = dbo.tblStatut.refStatut
ORDER BY dbo.tblCommande.Statut, dbo.tblClient.NomCompagnie

can I get a product of dbo.tblCommandeProduit.Prix X dbo.tblCommandeProduit.Discoun X dbo.tblCommandeProduit.Qte AS NET PRICE ?
 
SELECT ...
,dbo.tblCommandeProduit.Prix * dbo.tblCommandeProduit.Discoun * dbo.tblCommandeProduit.Qte AS [PRIX NET]
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks...
Getting error because of 0 values as discount.
could I use a case to select discount, if 0 then dbo.tblCommandeProduit.Prix * dbo.tblCommandeProduit.Qte AS [PRIX NET]
else
dbo.tblCommandeProduit.Prix * dbo.tblCommandeProduit.Discoun * dbo.tblCommandeProduit.Qte AS [PRIX NET]
end
 
If SQL-Server syntax:
SELECT ...
,dbo.tblCommandeProduit.Prix * (CASE WHEN dbo.tblCommandeProduit.Discoun=0 THEN 1 ELSE dbo.tblCommandeProduit.Discoun END) * dbo.tblCommandeProduit.Qte AS [PRIX NET]
..
If JetSQL syntax:
SELECT ...
,dbo.tblCommandeProduit.Prix * IIf(dbo.tblCommandeProduit.Discoun=0, 1, dbo.tblCommandeProduit.Discoun) * dbo.tblCommandeProduit.Qte AS [PRIX NET]
..

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Is it possible to obtain a grand total of NET PRICE ?
 
Have a look to UNION

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Can something like this be accomplished ?


Code:
SELECT     TOP 100 PERCENT dbo.tblClient.NomCompagnie, dbo.tblCommande.POClient, dbo.tblStatut.StatutCommande, dbo.tblCommande.DateCreation, 
                      dbo.tblCommandeProduit.Discount, dbo.tblCommandeProduit.NomProduit, dbo.tblCommande.PO, dbo.tblCommandeProduit.Qte, 
                      dbo.tblCommandeProduit.Prix, 
                      dbo.tblCommandeProduit.Prix * (CASE WHEN dbo.tblCommandeProduit.Discount = 0 THEN 1 ELSE dbo.tblCommandeProduit.Discount END) 
                      * dbo.tblCommandeProduit.Qte AS [PRIX NET]
FROM         dbo.tblCommande INNER JOIN
                      dbo.tblCommandeProduit ON dbo.tblCommande.refCommande = dbo.tblCommandeProduit.refCommande INNER JOIN
                      dbo.tblClient ON dbo.tblCommande.refClient = dbo.tblClient.refClient INNER JOIN
                      dbo.tblStatut ON dbo.tblCommande.Statut = dbo.tblStatut.refStatut
WHERE     (dbo.tblStatut.StatutCommande = N'On quote')
ORDER BY dbo.tblCommande.Statut, dbo.tblClient.NomCompagnie
union
SELECT     TOP 100 PERCENT dbo.tblClient.NomCompagnie, dbo.tblCommande.POClient, dbo.tblStatut.StatutCommande, dbo.tblCommande.DateCreation, 
                      dbo.tblCommandeProduit.Discount, dbo.tblCommande.PO, dbo.tblCommandeProduit.Qte, dbo.tblCommandeProduit.Prix, 
                      dbo.tblCommande.ActivationDate, 
                      dbo.tblCommandeProduit.Prix * dbo.tblCommandeProduit.Qte - dbo.tblCommandeProduit.Prix * dbo.tblCommandeProduit.Discount * dbo.tblCommandeProduit.Qte
                       AS [PRIX NET]
FROM         dbo.tblCommande INNER JOIN
                      dbo.tblCommandeProduit ON dbo.tblCommande.refCommande = dbo.tblCommandeProduit.refCommande INNER JOIN
                      dbo.tblClient ON dbo.tblCommande.refClient = dbo.tblClient.refClient INNER JOIN
                      dbo.tblStatut ON dbo.tblCommande.Statut = dbo.tblStatut.refStatut
WHERE     (dbo.tblStatut.StatutCommande = N'In production') AND (MONTH(dbo.tblCommande.ActivationDate) = 9)
ORDER BY dbo.tblCommande.Statut, dbo.tblClient.NomCompagnie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top