Narrow down the recordset

  • Alorenzini,

    CASE Repflag =

    WHEN RepFlag = (Select Repflag From #Temp WHere r.ConsultantID = d.COnsultantID ) THEN 'x'

    WHEN repFlag =(Select Repflag From #Temp WHere r.ConsultantID = d.COnsultantID AND d.CurrentLevelXID = r.AchieveLevel AND r.PeriodEndDate <> MAX(r.PeriodENdDate ) THEN ' '

    ELSE

    ' '

    If you do your case like this there is no need to even join the tables, unless you need the other columns down the line.

  • Jonnie Pettersson (2/13/2008)


    Now I'm lost 😉

    if you implemented this...

    AND Con.Periodenddate <= (SELECT TOP 1 PeriodEndDate FROM

    (SELECT TOP 2 ConsultantID, AchieveLevel,

    Max(PeriodEndDate) AS PeriodEndDate

    FROM #C

    WHERE ConsultantID = Con.ConsultantID

    GROUP BY ConsultantID, AchieveLevel

    ORDER BY PeriodEndDate DESC) AS x

    ORDER BY PeriodEndDate ASC)

    ...you should not have any repromotions at the current consultant level...

    I'm in uspS_DownlineRepromotions2 with this code...and it will not return any repromotions on the current level...therefore I dont see the problem with the main as long as the join is correct...but as I say...I'm lost now 😀

  • That is totally correct. I implemented the CASE statement and now I lost all the repromote flags.

    Thanks,
    Art
    Database Analyst
    Tastefully Simple, Inc.

    alorenzini@tastefullysimple.com
    " Some days, it's not even worth chewing through the restraints!

  • After some exhaustive anaysis on the underlying data, I found that it was a data issue. Once I fixed that, these procs worked just fine. I would like to thank eveybody who contributed. It really was a big help.

    Thanks again.

    Thanks,
    Art
    Database Analyst
    Tastefully Simple, Inc.

    alorenzini@tastefullysimple.com
    " Some days, it's not even worth chewing through the restraints!

  • Good deal. I am glad everthing worked out and thanks for the feedback.

Viewing 5 posts - 121 through 124 (of 124 total)

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