Forum Replies Created

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

  • RE: Sorting in order of my choice

    Jeffrey Williams 3188 - Sunday, October 7, 2018 12:09 PM

    saravanatn - Sunday, October 7, 2018 12:00 PM

  • RE: Sorting in order of my choice

    Jeffrey Williams 3188 - Sunday, October 7, 2018 11:40 AM

    In this particular case - we can shorten it to:


    Order By
     ...

  • RE: Find and replace third occurrence of the string

    Jeff Moden - Sunday, October 7, 2018 11:31 AM

    saravanatn - Saturday, October 6, 2018 11:29 PM

    October 7, 2018 at 11:55 am

    #2008470

  • RE: Sorting in order of my choice

    Thom A - Sunday, October 7, 2018 5:53 AM

    saravanatn - Sunday, October 7, 2018 5:02 AM

    October 7, 2018 at 11:15 am

    #2008465

  • RE: Sorting in order of my choice

    Eirikur Eiriksson - Sunday, October 7, 2018 6:55 AM

    Few options, here are three of those
    😎


    USE TEEST;
    GO
    SET NOCOUNT ON;

    DECLARE @NAME...

  • RE: Sorting in order of my choice

    Thom A - Sunday, October 7, 2018 3:02 AM

    You could make it more succinct by using LEFT, but it's probably as efficient...

  • RE: Running total over partition order

    Eirikur Eiriksson - Monday, October 1, 2018 5:09 AM

    saravanatn - Monday, October 1, 2018 2:28 AM

  • RE: Running total over partition order

    pjrpjr7 - Sunday, September 30, 2018 5:16 PM

    Hi,

    I need to find the running total for each group order by date.
    So the query is select.......,...

  • RE: How do I merge a set of records

    mw_sql_developer - Thursday, September 27, 2018 3:05 PM


    IF Object_id('tempdb..#t') IS NOT NULL 
      DROP TABLE #t; 

    SELECT '0010970115'  AS EMP, 
           '20160701'    AS EffectiveDate, 
           '20170131'    AS TermDate, 
           'Elig_Change' AS SpanReason 
    INTO   #t 

    INSERT INTO #t 
                (emp, 
                 effectivedate, 
                 termdate, 
                 spanreason) 
    SELECT '0010970115', 
           '20170201', 
           '20171130', 
           'Elig_Change' 

    INSERT INTO #t 
                (emp, 
                 effectivedate, 
                 termdate, 
                 spanreason) 
    SELECT '0010970115', 
           '20171201', 
           '20171231', 
           'Elig_Change' 

    INSERT INTO #t 
                (emp, 
                 effectivedate, 
                 termdate, 
                 spanreason) 
    SELECT '0010970115', 
           '20180101', 
           '20180930', 
           'Elig_Change' 

    INSERT INTO #t 
                (emp, 
                 effectivedate, 
                 termdate, 
                 spanreason) 
    SELECT '0010970115', 
           '20180407', 
           '20180811', 
           'LTI' 

    INSERT INTO #t 
                (emp, 
                 effectivedate, 
                 termdate, 
                 spanreason) 
    SELECT '0010970115', 
           '20180609', 
           '20180708', 
           'HOSPICE'; 

    SELECT table1.emp, 
           Min(table1.effectivedate) AS startdate, 
           Max(table2.termdate)      AS enddate, 
           table1.spanreason 
    FROM   (SELECT *, 
                   Row_number() 
                     OVER ( 
                       partition BY emp, spanreason 
                       ORDER BY effectivedate) AS rnk 
            FROM   #t)table1 
           INNER JOIN (SELECT *, 
                              Row_number() 
                                OVER ( 
                                  partition BY emp, spanreason 
                                  ORDER BY effectivedate) AS rnk 
                       FROM   #t)table2 
                   ON table1.rnk + 1 = table2.rnk 
    GROUP  BY table1.emp, 
              table1.spanreason ;

    Output:
    emp    SpanReason    startdate    enddate
    0010970115    Elig_Change    20160701    20180930
    0010970115    HOSPICE    20180609    20180708
    0010970115    LTI    20180407    20180811

  • RE: Need help in writing Query

    Prakash-485822 - Sunday, September 30, 2018 6:25 AM

    Need help in writing query. I table Requestdetails which contain the below data.

    PkeyRequestIdStateNameResolverGroupDateCreated
    1123Resolved299/27/18 15:16
    2123Acknowledge299/27/18 15:16
    3123Assign To299/27/18 15:08
    4123Assign...

  • RE: LEFT JOIN

    mediacommentry - Wednesday, September 26, 2018 7:05 AM

    Hi,

    I have a View, [ViewName] when I select from this view I get 10 rows back.
    Now I...

  • RE: Top amount invoiced query help!

    LinksUp - Thursday, September 20, 2018 11:41 AM

    misstryguy - Thursday, September 20, 2018 10:19 AM

    Thanks for...

  • RE: Joining tables

    venuvedham16 - Tuesday, August 21, 2018 11:43 AM

    Hi,

    I am trying to build sql statement, but got struck. Any inputs please?

  • RE: Joining tables

    venuvedham16 - Tuesday, August 21, 2018 11:43 AM

    Hi,

    I am trying to build sql statement, but got struck. Any inputs please?

  • RE: Today's Random Word!

    TomThomson - Sunday, August 19, 2018 7:55 PM

    DesNorton - Friday, August 17, 2018 11:17 PM

  • Viewing 15 posts - 76 through 90 (of 210 total)