Forum Replies Created

Viewing 15 posts - 76 through 90 (of 258 total)

  • RE: Using Count

    Thanks a lot, the time was messing me up. Corrected that and it works fine.

  • RE: OR statement issue

    That worked. Thanks a lot. Final code

    Select ConsultantID

    , ConsultantName

    , SponsorID

    ,RecruitCOunt

    ,AchieveDate

    ,PurchaseAmount

    ,Active from #temp1

    WHERE Active = 1

    UNION ALL

    Select t.ConsultantID

    , t.ConsultantName

    , t.SponsorID

    ,t.RecruitCOunt

    ,t.AchieveDate

    ,SUM(v.PurchaseAmount) AS PurchaseAmount

    ,t.Active

    from #temp1 t

    INNER...

  • RE: OR statement issue

    I am trying the UnionStatements:

    Select ConsultantID

    , ConsultantName

    , SponsorID

    ,RecruitCOunt

    ,AchieveDate

    ,PurchaseAmount

    ,Active from #temp1

    WHERE Active = 1

    UNION ALL

    Select ConsultantID

    , ConsultantName

    , SponsorID

    ,RecruitCOunt

    ,AchieveDate

    ,PurchaseAmount

    ,Active from #temp1

    UNION ALL

    Select t.ConsultantID

    , t.ConsultantName

    , t.SponsorID

    ,t.RecruitCOunt

    ,t.AchieveDate

    ,SUM(v.PurchaseAmount) AS...

  • RE: Filter without dynamic SQL

    Where

    gci.IssueDate >=@BeginIssueDate

    AND gci.IssueDate <= @EndIssueDate

    --AND gct.XID = @CertType

    and 1 =

    case

    when @CertType is null then 1

    else

    case

    when gct.XID = @CertType...

  • RE: Summing too many rows

    Thanks for the tip. This is what it turned out to be.

    SELECT v.ConsultantID

    ,SUM(PurchaseAmount) AS PORSalesTotal

    ,'PORSalesPoints' =

    CASE

    WHEN SUM(PurchaseAmount) > 15000 And NACDATE <= '06/30/2008' then SUM(PurchaseAmount...

  • RE: Summing too many rows

    There is my duh for the day. That worked great. How would I go about taking the total and then another field assign points to it.

    So lets say I have...

  • RE: Filter without dynamic SQL

    I found out what was going on, it was on my sise so your code is working. But is there a way to use the same code to manipulate more...

  • RE: Filter without dynamic SQL

    Oops not quite right. Do I need to set up a case statement for each of the filter options?

    Where

    gci.IssueDate >=@BeginIssueDate

    AND gci.IssueDate <= @EndIssueDate

    --AND gcv.XID = @VoidREasonFilter

    and 1 =...

  • RE: Filter without dynamic SQL

    That worked great! I suppressed the NULLS by the following:

    Where

    gci.IssueDate >=@BeginIssueDate

    AND gci.IssueDate <= @EndIssueDate

    --AND gcv.XID = @VoidREasonFilter

    and 1 = case when @VoidREasonFilter is null then 1 else

    ...

  • RE: Filter without dynamic SQL

    I can go after it this way:

    DECLARE @BeginIssueDate Datetime

    DECLARE @EndIssueDate DateTime

    DECLARE @VoidReasonFilter VARCHAR(50)

    SET @BeginIssueDate = '01/01/2008'

    SET @EndIssueDate ='04/01/2008'

    SET @VoidReasonFilter = 'All Reason Codes'

    IF @EndIssueDate > GETDATE()

    BEGIN

    ...

  • RE: Creating matrix via TSQL

    The code as it sits now:

    ...

    CREATE TABLE #Temp1 (

    id_num int IDENTITY(1,1),

    COnsultantID char(20),

    SponsorID char(20),

    RecruitCOunt INT,

    AchieveDate DateTime

    )

    INSERT iNTO #Temp1

    Select ConsultantID, SponsorID, COUNT(*)...

  • RE: Creating matrix via TSQL

    Believe me I will take that to heart. I kinda got dumped into this because the DBA Developer resigned. So I am trying to get up to speed as quickly...

  • RE: Creating matrix via TSQL

    That worked fantastic. One of these days I will get this TSQL figured out...

    One more quick question. for the column Name (eg. JAN) I would like to format as JAN...

  • RE: Creating matrix via TSQL

    No I see where the UNION ALL comes in. I think I have an issue with Over-thinking things some time.:D

    Declare @MonthsOut int, @StartDate datetime, @EndDate datetime, @COnsultantID char(20)

    Set @ConsultantID =...

  • RE: Creating matrix via TSQL

    OK, I did this:

    Select (Select ACtivityDesc FROM #ActivitySummary WHERE ActivitySort = 2) AS ActivtySummary,

    Jan = sum(case when month(v.PeriodEndDate) = 1 AND V.consultantID=@consultantID then PurchaseAmount else 0 end),

    Feb =...

Viewing 15 posts - 76 through 90 (of 258 total)