Forum Replies Created

Viewing 15 posts - 1,081 through 1,095 (of 1,246 total)

  • RE: Query with Multiple Columns

    sharonmtowler (8/5/2015)


    someone sent me this from a different forum

    ROW_NUMBER() OVER (PARTITION BY S.SESSIONID ORDER BY PL.enter_time) AS location_sequence_id

    works like a charm!!!

    If SessionID was a necessary part of the solution, you...

  • RE: Query with Multiple Columns

    This should illustrate how to do it in SQL... (Since no one ever takes the "let the reporting software do it" advise.)

    -- Test Data --

    IF OBJECT_ID('tempdb..#Transfers') IS NOT NULL

    DROP...

  • RE: Query with Multiple Columns

    sharonmtowler (8/5/2015)


    I want to know if it is possible to do the following;

    I have patients that may have been transferred to different locations(see below)

    location_name enter_time

    4D04 2/9/15 2:35

    4D14 2/9/15 8:44

    RECOVERY 3...

  • RE: non trusted constraints vs performance

    newbieuser (8/4/2015)


    Friends,

    What are other causes that make check/FK constraints non trusted because we normally don't enable/disable constraints during loads or scripts or anything. We always drop and re-create...

  • RE: Recursive update on 3000 rows

    The attached script should help you generate usable test data... Simply plug in the table name (line 12) and the number of rows you want (line 18)

    If you need to...

  • RE: Storing data from temp table into a variable

    There are a few way of doing this, depending on what you want to do.

    If your SSRS parameter is single single valued parameter (the user can select only a single...

  • RE: Storing data from temp table into a variable

    If you're trying to create a pick list for an SSRS parameter, you're going about it all wrong.

    Each SSRS parameter (that you want to have a pick list) just needs...

  • RE: Need help in Pivot Table with Column Names to Rows.

    Rahuul (8/2/2015)


    Thanks a lot Jason.

    Saved my day!!

    You're welcome! Glad to help. 🙂

    On another note, could it be done using Pivot?

    Yes. There are several ways to write this query.

  • RE: Need help in Pivot Table with Column Names to Rows.

    This should give you what you're looking for...

    -- Test data --

    IF OBJECT_ID('tempdb..#temp') IS NOT NULL

    DROP TABLE #temp;

    CREATE TABLE #temp (

    FY INT,

    REVCODE VARCHAR(3),

    Jul INT,

    Jun INT

    );

    INSERT #temp (FY,REVCODE,Jul,Jun) VALUES

    (2015,'BNQ',1054839,2000000),

    (2015,'FNB',89032,1000000),

    (2015,'RS',1067299,3000000);

    -- The solution --

    SELECT

    t.FY,

    x.[Month],

    SUM(CASE...

  • RE: how to update values based on column into multiple columns in another table

    Try this...

    UPDATE h SET

    h.CHANNEL1 = vc.C1,

    h.CHANNEL2 = vc.c2

    FROM

    #Hori h

    JOIN (

    SELECT

    v.FILTER,

    MAX(CASE WHEN v.CHANNEL = 1 THEN v.VALUE END) AS C1,

    MAX(CASE WHEN v.CHANNEL = 2 THEN v.VALUE END) AS...

  • RE: Query taking time

    PJ_SQL (7/31/2015)


    I get this error :

    Invalid column name 'RN'.

    Have a look at the following... I included two different solutions... Either approach could be faster than the other depending on the...

  • RE: Query taking time

    Luis Cazares (7/30/2015)


    What are you expecting to accomplish with the subquery? It basically compares one column to itself joined by the same condition.

    Looks like an expensive attempt to get the...

  • RE: Multiple Columns to appear on One Row

    tstagliano (7/30/2015)


    Not sure I am following what you are asking. My current output would look something like this.

    Country_code Local_client_code Local_client_name ...

  • RE: cumulative average without cursor

    Yea... I see what you did. Sounds like you're the one with the correct interpretation of the requirements. Nice solution BTW. With a couple of indexes it would be easy...

  • RE: cumulative average without cursor

    Robert klimes (7/29/2015)


    The results aren't quite right(terms 2 and 3 are low) but I will have a look to see if I can tweak this.

    I read "Cumulative Average" to mean...

Viewing 15 posts - 1,081 through 1,095 (of 1,246 total)