Forum Replies Created

Viewing 15 posts - 2,206 through 2,220 (of 2,458 total)

  • RE: Max of 2 dates

    dwain.c (7/3/2013)


    Gentlemen,

    We are all gentlemen here right? Is it too late to join the party, or skirmish as the case may be?

    How's this one stack up in your test...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Need to derive avg execuion time for 3 tables

    No problem!

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Need to derive avg execuion time for 3 tables

    I think this will do the trick:

    -- (1) Create table and sample data:

    DECLARE @x TABLE

    (TableName varchar(3) not null,

    BeginTime datetime not null,

    EndTime datetime not null);

    INSERT @x

    SELECT 'T1', '2013-06-02...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Explanation of LIKE '%[0-9]%'?

    This should be helpful too: MSDN match expression article.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: General Question

    This is an interesting read about an in-house DSS application built by NASA for their Program Managers:

    The NASA Program Management Tool:A New Vision in Business Intelligence.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Magic Quadrant for Monitoring Software?

    My $0.02...

    The two products I have had the most experience with are Idera SQL Diagnostics Manager and Quest (Foglight & Spotlight).

    I'm personally a huge fan of Idera SQL...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Date Query Issue

    SQL_FS (6/27/2013)


    What about this?

    SELECT

    SeqNo

    , coalesce(Data.startYear, src.startYear) AS [startYear]

    , coalesce(data.endYear, src.endYear) AS [endYear]

    , coalesce(data.Number, src.Number) AS [Number]

    , src.name

    FROM @tblJobHist_src src

    OUTER APPLY

    (

    SELECT

    min(startYear) AS [startYear]

    , max(endYear) AS [endYear]

    , sum(Number) AS [Number]

    FROM @tblJobHist_src src2

    WHERE

    src2.name...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: "Running totals" query

    Barkingdog (6/27/2013)


    I had never heard of a "triangular" join but I verified it is incredibly slow. . (I actually took the very data involved, exported it to a CSV...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Date Query Issue

    Thank you everyone. I figured it out... Not the prettiest solution but it works.

    -- With the numbers

    WITH islands AS

    (SELECT t1.SeqNo, t1.StartYear, t1.EndYear, t1.name

    FROM @tblJobHist_src t1

    JOIN @tblJobHist_src t2...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Date Query Issue

    Sean Lange (6/26/2013)


    Alan have you looked at islands and gaps. I am pretty sure this is exactly what you need here.

    http://www.sqlservercentral.com/articles/T-SQL/71550/%5B/url%5D

    It is, thanks Sean. I don't have my Ben Gan...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    Sean Pearce (6/26/2013)


    Alan.B (6/26/2013)


    Sean Pearce (6/26/2013)


    Alan.B (6/25/2013)


    Which is why I included two solutions: My original solution which I believe is correct and one which was cleaner and faster than the...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    Sean Pearce (6/26/2013)


    Alan.B (6/25/2013)


    Which is why I included two solutions: My original solution which I believe is correct and one which was cleaner and faster than the one Michael posted.

    Do...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    J Livingston SQL (6/25/2013)


    Alan.B (6/25/2013)


    Michael Valentine Jones (6/25/2013)


    select top 1

    a.[Date]

    from

    (

    select top 1 b.[Date] from table1 b order by b.[Date] desc

    union

    select top 1 c.[Date] from table2 c order by c.[Date] desc

    )...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    Michael Valentine Jones (6/25/2013)


    select top 1

    a.[Date]

    from

    (

    select top 1 b.[Date] from table1 b order by b.[Date] desc

    union

    select top 1 c.[Date] from table2 c order by c.[Date] desc

    ) a

    order by

    a.[Date] desc

    I think...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Max of 2 dates

    Shadab Shah (6/25/2013)


    J Livingston SQL (6/25/2013)


    Shadab Shah (6/25/2013)


    I search for Date functions for finding the max of the 2 dates. But such function does not exits.

    Is there any easy way...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 2,206 through 2,220 (of 2,458 total)