Skip to Content
author's profile photo Former Member
Former Member

Case statement for Tax rate

Hi All,

I'm looking for case statement when CST rate is 2% it should show 2, when VAT rate is 5% it should 5, when VAT rate is 12.5%, it should show 12.5.

I'm using following query but i'm getting duplicate entry

For ex:

(case when statype='1' then '5'

when statype ='4' then '2' else end '0' as 'Taxrate')

I need only the taxrate which was used in document(no duplicates).



Thanks & Regards,

Saikrishna.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2015 at 12:24 PM

    Hi Sai,

    You can use tax rate column in tax table

    For example

    1. INV4 table for AR invoice
    2. PCH4 for AP invoice
    3. POR4 for Purchase order....so on
    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Sai,

      You won't get error , if you use that sub query.Refer the below query

      SELECT

      T0.[DocNum],

      T0.[DocDate],

      T3.[DocNum],

      T3.[DocDate],

      T3.[CardCode],

      T3.[CardName],

      T2.[Quantity],

      T2.[unitMsr],

      T2.[Price],

      T3.[U_BEDType],

      (t2.price*12.5/100) as 'Excise Duty',

      (select avg(taxrate) from PQT4 where statype='-90' and docentry= t3.docentry) as 'BED Rate',

      (t2.price+(t2.price*12.5/100)) as 'Gross Rate' ,

      T3.[U_STType],

      (select taxrate from PQT4 where LineNum =t1.LineNum and docentry= t3.docentry) as 'ST Rate',

      (((t2.price+(t2.price*12.5/100))*(select avg(taxrate) from PQT4 where statype='1' and docentry= t3.docentry))/100) as 'ST Amt',

      ((t2.price+(t2.price*12.5/100))+(((t2.price+(t2.price*12.5/100))*(select avg(taxrate) from PQT4 where statype='1' and docentry= t3.docentry))/100)) as 'Bill Rate',

      T3.U_Transrate,

      T4.[PymntGroup] as 'Payment terms'

      FROM OPRQ T0

      INNER JOIN PRQ1 T1 ON T0.[DocEntry] = T1.[DocEntry]

      left join PQT1 T2 on t2.baseentry=t0.docentry and t2.baseline=t1.linenum

      INNER JOIN OPQT T3 ON T2.[DocEntry] = T3.[DocEntry]

      left JOIN OCTG T4 ON T3.[GroupNum] = T4.[GroupNum]

      WHERE T1.[Dscription] =[%0] and T0.[DocNum] =[%1]

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.