This topic is locked
[SOLVED]

 Query Designer - SQL

10/6/2011 2:01:20 PM
PHPRunner General questions
D
dclex author

Hi Guys,
I was hoping someone could check my code as I have a syntax error with the If Statement. The outcome I am looking for would be that if the Rate Type input = Lump SUm, that Rate would be multiplied by 1. If not, Rate would be multiplied by the Est. Quantity. In either case, a "SubTotal" would be calculated.
Thanks in advance.
SELECT

Key,

Client,

Project,

Project Number,

Project Manager,

Service Type,

Work Task,

Rate Type,

Est. Quantity,

Rate,

IF Rate Type="Lump Sum" THEN Rate1=Subtotal

[ELSE Rate
Est. Quantity=Subtotal]

END AS SubTotal

FROM Budget Items

C
cgphp 10/6/2011
SELECT

`Key`,

Client,

Project,

`Project Number`,

`Project Manager`,

`Service Type`,

`Work Task`,

`Rate Type`,

`Est. Quantity`,

Rate,

IF(`Rate Type`="Lump Sum", Rate*1, Rate*`Est. Quantity`) AS SubTotal

FROM `Budget Items`


I advise you to use fields name without spaces.

D
dclex author 10/6/2011

I appreciate the note, do you have any input on the code?
Thanks again

C
cgphp 10/6/2011

Have you just tried my code solution above ?

D
dclex author 10/6/2011

You are the man Cristian! Excellent work!