Friday, March 30, 2012

IF in a Select statement

Hi,

What would be the best way to do this, I have a table like so:


JobID Estimate1 Estimate2
1 20.00 25.00
2 52.12 47.31
3 45.00 34.00
4 60.00 65.00

and I need to create an SQL query that will grab the Sum of the highest estimates, ie (25.00 + 52.12 + 45.00 + 65.00)

I was hoping to do something similar to the SUMIF function in excel:
SELECT SUMIF(Estimate1>=Estimate2, Estimate1, Estimate2) FROM Estimates
but I haven't seen anything simular to that in the documetation.You should be able to use aCASE statement to accomplish this.

Terrisql

No comments:

Post a Comment