Query Help Kind of Tricky??

  • Ok peeps maybe someone can help me out here!! the below QUERY basically is a straight select with 1 real condition

    which is Transaction_Type LIKE 'Down Time%'

    but what i need is a query that says if i do have a

    Transaction_Type LIKE 'Down Time%' which is select below run as normal but if i DONT HAVE A Transaction_Type LIKE 'Down Time%' i'll hard code the select??? Make sense

    Bottom Line i need with Transaction_Type LIKE 'Down Time%' and

    Transaction_Type NOT LIKE 'Down Time%' all in one select statement somekind of way

    example

    Joe Smith 2.00 120 = WITH Transaction_Type LIKE 'Down Time%

    Jane smith 0.00 0.00 = WITH OUT Transaction_Type LIKE 'Down Time%

    SELECT TblMasterTrans.User_ID, Time_Spent, Downtime

    FROM TblMasterTrans,TblContractInfo_SubMenuTable

    WHERE Date_Opened Between '06-01-08' And '06-07-08'

    AND TblMasterTrans.Task_Number = TblContractInfo_SubMenuTable.Task_Number

    AND TblMasterTrans.User_ID = TblContractInfo_SubMenuTable.User_ID

    AND Transaction_Type LIKE 'Down Time%'

    GROUP BY TblMasterTrans.User_ID

  • HI ,

    You can Use a case option in select statement when transactiontype is LIKE 'Down Time% then

    concatenate ''= transactiontype LIKE 'Down Time%" else do it in opposite manner

    This will give you both the records with and without Transaction Type,

    Hope this is what you are looking for

    kindly make it clear if this not the thing you looked at

    Rajesh

  • Hello there Where excatly would you use this CASE statement?

  • select

    case

    when Transaction_Type like 'Down Time%'

    then Transaction_Type

    else 'my hard coded text'

    end

    from mytable

Viewing 4 posts - 1 through 3 (of 3 total)

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