14
Answers

Need Help in solving SQL QUERY

Dorababu Meka

Dorababu Meka

13y
1.4k
1
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)