Forum Replies Created

Viewing 15 posts - 256 through 270 (of 321 total)

  • RE: Problem w/ Grouping & Count

    SELECT

     A.FacilityID,

     SUM( CASE WHEN DateHired is not null THEN 1 ELSE 0 END) AS 'HireCnt',

     SUM( CASE WHEN DateHired is null AND A.Facility IS NOT NULL THEN 1 ELSE 0...

  • RE: Problem w/ Grouping & Count

    Nice...

    FULL OUTER JOIN is not going to give you the right result : )

    LEFT JOIN was K but NOT FULL.

    If you do FULL you are going to end up with...

  • RE: Time Formatting

    Srry wrong calculations before....

    this is the right solution

    Declare @PartsRemaining float

    DECLARE @Speed float

    SELECT @PartsRemaining=300,@Speed=50

    SELECT

    CASE WHEN LEN(LTRIM(STR(CAST(@partsRemaining / @Speed as INT))))<2 THEN '0' ELSE '' END +

    LTRIM(STR(CAST(@partsRemaining...

  • RE: Time Formatting

    SELECT

    CASE WHEN LEN(LTRIM(STR(CAST(@partsRemaining / @Speed as INT))))<2 THEN '0' ELSE '' END +

    LTRIM(STR(CAST(@partsRemaining / @Speed as INT)))+':'

    +REPLICATE('0',2-LEN(LTRIM(STR(CAST((CAST(@partsRemaining / @Speed * 100 as INT)%100)*60...

  • RE: Problem w/ Grouping & Count

    Should be Left Join  not Right Join

  • RE: Time Formatting

    This will give you the HOURS and minutes

     

    Declare @PartsRemaining float

    DECLARE @Speed float

    SELECT @PartsRemaining=100000,@Speed=50000

    SELECT LTRIM(STR(CAST(@partsRemaining / @Speed as INT)))+':'

    +REPLICATE('0',2-LEN(LTRIM(STR(CAST((CAST(@partsRemaining / @Speed * 100 as INT)%100)*60...

  • RE: Select Statement Errors..??

    I don't know why this

    Select FundId From C_Funds

    Where FundId NOT IN (Select ActualId from Product)-- Find New Funds

    is not working ...It should

  • RE: Time Formatting

    GETDATE() and DATEDIFF should help you do your job

  • RE: Select Statement Errors..??

    Should work ...

    PS. you have a column ActualId in C_Funds?

  • RE: Select Statement Errors..??

    Hmm that is really strange now...

    Just try:

    Select ActualId, FundID

    From Product FULL OUTER JOIN

    C_Funds ON ActualID=FundID

    --Where ActualId IS NULL --return new FundID

    --Where FundId IS NULL --return new ActualID

     

    with this Query you can...

  • RE: Select Statement Errors..??

    The first statement was with the mistake the sec is correct ActualId is in fact FundId that was your mistake

  • RE: Select Statement Errors..??

    here....

    Select FundId From C_Funds Where ActualId Not in(Select ActualId from Product)-- Find New Funds

     

    Select FundId From C_Funds Where FundId Not in(Select ActualId from Product)-- Find New Funds

     

     

  • RE: Max of date from multiple columns

    This is a more readable form

    SELECT TOP 1

       myVersion,

       Case

          WHEN lastdatea>=lastdateb AND lastdatea>=lastdatec AND lastdatea>=lastdated THEN lastdatea

          WHEN lastdateb>=lastdatea AND lastdateb>=lastdatec AND lastdateb>=lastdated THEN lastdateb

          WHEN lastdatec>=lastdatea AND...

  • RE: Max of date from multiple columns

    For 5 rows... you can pick wich plan you want...

     

    PS: the prev plan returns the full row from your table

  • RE: Max of date from multiple columns

    1 Extra column can change the aproach totally...

    But I would say to stick to a more complicated CASE than 3 table scans...

    SELECT TOP 1

       myVersion,

       Case

          WHEN lastdatea>lastdateb...

Viewing 15 posts - 256 through 270 (of 321 total)