how to use switch statement to get multiple values

  • Hi all,

    For eg.,

    I have a LeaveType table that has values given below:

    ID LeaveType Allotedleave

    -----------------------------------------

    1 Loss of pay 0

    2 Permission 0

    3 Casual 20

    4 Maternity 90

    5 Paternity 5

    i want the query to return LossofPay and Permission by default, Maternity and Paternity should be displayed based on gender and Casual leave should be displayed only if the user has alloted leave balance in their account i.e., if the user has used all his/her leaves in the casual leave category, tthen the query should not return CL type

    Thanks,

  • It would be best if you break your table structure into 3 tables but for this particular architecture there is no way unless something like this:

    SELECT * FROM LeaveType WHERE ID IN (1,2)

    UNION

    SELECT * FROM LeaveType WHERE ID IN (4,5) AND [F_Gender] = 'Male'

    UNION

    SELECT * FROM LeaveType WHERE ID = 3 AND LeaveType > 0

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply