• Chrissy,

    I took a look at the guidelines, and I can't seem to figure out exactly how to post the data the way they've shown. I've done my best to make it presentable and easy to read. To answer your question; 'ALL' is not a field within TransCode, there are several different data including 'BUY' and 'SELL'. When I use 'ALL' as a variable, I would just like the column to return everything back. (i.e - BUY, SELL, HOLD, CONSTRAIN, ON ACCOUNT, etc.)

    BEGIN

    DECLARE @idnum varchar

    SELECT @idnum = 1

    DECLARE @TC varchar(50)

    SELECT @TC = 'BUY'

    SELECT B.GroupDetail, C.SecID, C.TransCode, C.Quantity, B.GroupId, C.PortfolioID

    FROM ERTutTransactions C

    INNER JOIN FinalGroupDetail B

    ON C.PortfolioID = B.PortfolioID

    AND B.GroupId = @idnum

    WHERE TransCode = @TC

    IF @TC = 'all'

    BEGIN

    SELECT B.GroupDetail, C.SecID, C.TransCode, C.Quantity, B.GroupId, C.PortfolioID

    FROM ERTutTransactions C

    INNER JOIN FinalGroupDetail B

    ON C.PortfolioID = B.PortfolioID

    AND B.GroupId = @idnum

    END

    [EDIT] P.S - None of my formatting is actually showing up, my apologies