Dorababu Meka

Dorababu Meka

  • 230
  • 8.3k
  • 1.7m

Need Help in solving SQL QUERY

Jul 30 2011 3:08 AM
I have my table data as follows


EMPID

FedTaxID

TaxType

Amount

1059

888888888

TX02

2000

1059

888888888

TX02

1000

1059

888888888

TX03

2000


I write a query to sum up the amount as follows

select SUM(Amount)
FROM
   tblTest
WHERE
   FedTaxID = '888888888'
   AND
   TaxTypeCode IN ('TX02', 'TX03')

But what i need is if TX03 exists 1 in the table i would like to add the amount multiple times means if i sum the total i will get 5000 but i would like to get 7000. If TX03 exists 1 time in the table i would like to add multiple times any idea please

Answers (14)