Forum Replies Created

Viewing 15 posts - 316 through 330 (of 533 total)

  • RE: join rows on table1.date between table2.dates

    You'll need to index your tables properly or your performance on this will be horrible, but I think this is basically what you're looking for:

    select a.id,

    a.CustomerNumber,

    a.AccessedDate,

    a.OperatorName,

    nlh.computer_nm,

    nlh.login_dt

    from action...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Reject duplicate Time within 01 minute

    with cteTest (RowNum, EmpID, LogTime)

    as

    (

    select ROW_NUMBER() OVER(PARTITION BY EmployeeID ORDER BY LogTime ASC),

    EmployeeID,

    LogTime

    from #Test

    )

    select cc.EmpID,

    cc.LogTime

    from cteTest cc

    left join cteTest cp

    on cp.EmpID = cc.EmpID

    and cp.RowNum = cc.RowNum - 1

    where DATEDIFF(ss, coalesce(cp.LogTime,...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Getting a datetime with minutes & seconds set to '00'

    This is slightly more efficient:

    SELECT DATEADD(hh, DATEDIFF(hh,0,'2010-04-04 14:15:02'), 0)

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: @@rowcount for use with UPSERT

    loki1049 (6/15/2010)


    How can you justify doing an upsert (update, if not exist, insert) with the use of @@rowcount. I am finding a lot of instances on the net where you...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Selecting the earliest month wrapping January to December

    scott.pletcher (6/11/2010)


    When I get a chance, I will write code to calc the variance of *any* set of numbers.

    At any rate, what solution did *you* provide? NONE. All...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Selecting the earliest month wrapping January to December

    scott.pletcher (6/11/2010)


    >> but when you post junior level code (non-SARG-able queries anyone?) <<

    Yes, I took the short-cut, because as *I* pointed out the code will result in full scan anyway.

    When...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Selecting the earliest month wrapping January to December

    scott.pletcher (6/11/2010)


    posted a very plausible case that broke your code.

    Depends. I was answering the request to select only rows with a gap of 2 or less...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Selecting the earliest month wrapping January to December

    scott.pletcher (6/11/2010)


    lol, you two are funny. I post code that actually works and you keep talking to each other about how "it can't be done". ROFLOL.

    I posted a...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Selecting the earliest month wrapping January to December

    Jeff Moden (6/10/2010)


    I'll also add what I said before. The data is being inserted in the order of 09, 11, 01 and everyone is just getting lucky with the...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: If Date value is less than current date set date value to today

    scott.pletcher (6/11/2010)


    but otherwise (such as in this case) this will result in a table scan even if there is an index on the DueDate.

    You could rephrase the query to...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: If Date value is less than current date set date value to today

    Lynn Pettis (6/11/2010)


    Another option:

    DECLARE @filterStart DATETIME

    DECLARE @filterEnd DATETIME

    SET @filterStart = '10/06/2010'

    SET @filterEnd = '10/07/2010'

    SELECT ...

    WHERE

    DueDate BETWEEN @filterStart AND @filterEnd

    ...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: If Date value is less than current date set date value to today

    I agree with Lynn, all that is needed to get the exact same records is:

    DECLARE @filterEnd DATETIME

    SET @filterEnd = '10/07/2010'

    SELECT ...

    WHERE CASE WHEN DueDate < @filterEnd

    scott.pletcher (6/10/2010)


    You've got it. ...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Need help in SQL , Subtract column based on the condition in the Row

    This is basically the same as Jason's but it's checking to make sure that the year is the same and the month is literally the next month. So depending...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: Bi-Weekly Pay Period Total Worked Hours

    create table #PayPeriod

    (

    payPeriodint,

    periodDescvarchar(50),

    startDatedatetime,

    endDatedatetime

    )

    insert into #PayPeriod (payPeriod, periodDesc, startDate, endDate)

    select 108, 'Period 12/20 - 01/02', '12/20/2009', '1/2/2010' union

    select 109, 'Period 01/03 - 01/16', '1/3/2010', '1/16/2010' union

    select 110, 'Period 01/17 - 01/30',...

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • RE: CTE Help - I Think I'm Close

    I could be missing something here ... I'll be honest, I didn't read through everything.

    But I'm not sure on this where the cte recursion comes into play on this ......

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

Viewing 15 posts - 316 through 330 (of 533 total)