locked
Need Help in Writting a SQL QUERY RRS feed

  • Question

  • User-1296120440 posted
    Below is Pending_Invoice Table having the data as shown Below :
    InvoiceNo BasicValue salestax VAT ExciseDuty
    MS208/11513 735 36.75 NULL 0 This is Basic Invoice Number having Sales Tax
    MS208/11513/ED 0 NULL NULL 88 Same Invoice Having Excise Duty- Check that Invoice Number is appended with '/ED' and observe that it has ExciseDuty Entry.
    MS208/11513/VAT NULL NULL 41.29 NULL Same Invoice Having VAT TAX - Check that Invoice Number is Appened with '/VAT' and Observe that it has VAT Entry

    Our Requirement is calculate Total Amount which will be Sum Of [Basic Amount] + [SalesTax] + [VAT Tax] +[Excise Duty]

    Required Result :

    InvoiceNo Total Amount
    MS208/11513 901.04 We have to show Total  Amount [Basic Amount] + [SalesTax] + [VAT Tax] +[Excise Duty] Corresponding to a Base Invoice Number [ MS208/11513 In this Case]

    Could you please help in writing a Query to Pull the data from Pending_Invoice Table and show the Total Amount against the Base Invoice Number as Expalined ?

    Let me know, if you need any clarifications from my end.

    Thursday, September 15, 2016 1:19 PM

Answers

  • User951722283 posted
    SELECT SUM(ISNULL(BasicAmount,0) + ISNULL(SalesTax,0) + ISNULL(VAT,0) + ISNULL(ExciseDuty,0)) AS Total 
    FROM Pending_Invoice
    WHERE InvoiceNo LIKE 'MS208/11513%'

    Try this

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 15, 2016 1:31 PM

All replies

  • User951722283 posted
    SELECT SUM(ISNULL(BasicAmount,0) + ISNULL(SalesTax,0) + ISNULL(VAT,0) + ISNULL(ExciseDuty,0)) AS Total 
    FROM Pending_Invoice
    WHERE InvoiceNo LIKE 'MS208/11513%'

    Try this

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 15, 2016 1:31 PM
  • User-1296120440 posted

    Thank you for your immediate reply.

    Friday, September 16, 2016 3:03 AM