Hi, and welcome to TSDN!
I have change the title of this thread to better describe it's contents.
Please read the
Posting Guidelines before posting in the forums, specifically the parts about using good thread titles, how to ask a question and using [code] tags.
Please describe your problem in greater detail. For example, explain what this query is supposed to achieve.
Also, note that this is an incomplete query. We can only give answers based on the information you give us. Bad information leads to bad answers.
Check out these links. (MySQL Reference Manual)
DECODE() function LEAST() function Moderator