Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

Trying to use IF statement and stuck now

$
0
0
Hi
Just a quick test I am looking at. I have an invoice generator, but if the field VATChargeable contains YES, then I want the Total field to be the sum of the Subtotal+VATAmount, but if it contains NO, then I want the Total field to be the same as the Subtotal field.
Any advice on how I can make this work please?
Thanks

SELECT
Job_No,
Invoice_Tax_Date,
Contract,
CustomerRef,
Order_Date,
File_No,
VAT,
CustomerName,
CustomerBuildingNumber,
Line1,
Line2,
Line3,
Line4,
Line5,
PostCode,
OrderSiteAddress,
SitesBuildingNumber,
SLine1,
SLine2,
SLine3,
SLine4,
SLine5,
SPostCode,
VATChargeable,
IFNULL((select ROUND(sum(InvoiceVAT),2) from labour where Job_No = job.Job_No), 0) as LabVAT,
IFNULL((select ROUND(sum(InvoiceSubtotal),2) from labour where Job_No = job.Job_No), 0) as Labsubtotal,
IFNULL((select ROUND(sum(Invoice),2) from labour where Job_No = job.Job_No), 0) as LabTotal,
IFNULL((select ROUND(sum(InvoiceVAT),2) from material where Job_No = job.Job_No), 0) as MatVAT,
IFNULL((select ROUND(sum(InvoiceSubtotal),2) from material where Job_No = job.Job_No), 0) as Matsubtotal,
IFNULL((select ROUND(sum(Invoice),2) from material where Job_No = job.Job_No), 0) as MatTotal,
(select Labsubtotal+Matsubtotal) as Subtotal,
(select LabVAT+MatVAT) as VATAmount,
[u][b]IF ((`VATChargeable` = 'YES' SET `Total` == 'Subtotal+VATAmount'; Else SET `Total` == 'Subtotal')),[/b][/u]
FROM job

Viewing all articles
Browse latest Browse all 2586

Trending Articles