Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to encorporate IF

Status
Not open for further replies.

dba112233

Programmer
Jan 10, 2006
39
US
How can I put an If statement saying If # RECORDS returned from the query below

IF # records returned is > 1 then
SUM(rmstranamt) AS rmstranamt10
ELSE

rmstranamt AS rmstranamt10

SELECT RMSFILENUM,
rmstranamt AS rmstranamt10 <-----If statement goes here base on if the amount of records found in select is >1 or not
FROM RFINANL
WHERE RMSTRANCDE = '10'
GROUP BY RMSFILENUM, rmstranamt
) AS rf10 ON rf10.RMSFILENUM = rm.RMSFILENUM
 
I want to return sum(rmstranamt) AS rmstranamt10 in cases where the same query produces > 1 records

In other words if this:

SELECT RMSFILENUM,
rmstranamt AS rmstranamt10
FROM RFINANL
WHERE RMSTRANCDE = '10'
GROUP BY RMSFILENUM, rmstranamt

produces > 1 records, then I don't want to return rmstranamt AS rmstranamt10, I want to return sum(rmstranamt) AS rmstranamt10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top