if statement in Informix SQL
Posted in 2008
Topics: General Discussion
Can someone help me to convert something like this in Informix SQL? select when arriveDT > appointmentDT then "OT" when arriveDT <= appointmentDT then "Normal" else "unknown" from contract thanks vchu -- Message posted via DBMonster.com http://www.dbmonster.com/Uwe/Forums.aspx/informix/200804/1
vchu via DBMonster.com wrote: > Can someone help me to convert something like this in Informix SQL? > > select > when arriveDT > appointmentDT then "OT" > when arriveDT <= appointmentDT then "Normal" > else "unknown" > from contract > > thanks > vchu Not so different: select case when arriveDT > appointmentDT then "OT" when arriveDT <= appointmentDT then "Normal" else "unknown" end from contract; Art S. Kagel Oninit
thanks a lots :) Art S. Kagel (Oninit) wrote: >> Can someone help me to convert something like this in Informix SQL? >> >[quoted text clipped - 6 lines] >> thanks >> vchu >Not so different: > >select > case > when arriveDT > appointmentDT then "OT" > when arriveDT <= appointmentDT then "Normal" > else "unknown" > end >from contract; > >Art S. Kagel >Oninit -- Message posted via http://www.dbmonster.com
On 11 Apr, 17:05, "Art S. Kagel (Oninit)" <a...@oninit.com> wrote: > vchu via DBMonster.com wrote: > > Can someone help me to convert something like this in Informix SQL? > > > select > > when arriveDT > appointmentDT then "OT" > > when arriveDT <= appointmentDT then "Normal" > > else "unknown" > > from contract > > > thanks > > vchu > > Not so different: > > select > case > when arriveDT > appointmentDT then "OT" > when arriveDT <= appointmentDT then "Normal" > else "unknown" > end > from contract; > > Art S. Kagel > Oninit Just a tiny note: if you're parsing your output, or want to put it into a temp table, you'll need to specify a name for the returned value (Informix will just return "(expression)" as the identifier. Just add your preferred identifier to the 'end' statement, e.g. select case <stuff> end arriveDT_status from contract (or whatever you want to call it). Malc