Forum Replies Created

Viewing 15 posts - 1 through 15 (of 68 total)

  • RE: without [union] in Query

    yes, i think when use FULL JOIN then it is a UNION.

    because the structure of tables(A&B) not same, i think i will be using FULL JOIN for queries.

  • RE: without [union] in Query

    Koen Verbeeck (8/1/2012)


    If you use UNION ALL the Distinct Sort operator will be removed from the query plan and performance won't be that bad. Are the two SELECT queries just...

  • RE: without [union] in Query

    Koen Verbeeck (8/1/2012)


    What's wrong with union?

    Since TSQL offers only union, intersect and except, any solution that I can think of right now involves union.

    because performance, the tables A,B have large...

  • RE: Max and Group By

    dwain.c (2/28/2012)


    Try this:

    SELECT id, date, [value]

    FROM (

    SELECT *, ROW_NUMBER() OVER (PARTITION BY id ORDER BY id, date DESC) AS rk

    FROM [temp]

    ) x

    WHERE rk = 1

    Thanks dwain.c

    It's working fine for me.

  • RE: Select Tree and Order by from another table

    Thank Jeff Moden for your support. 😀

  • RE: Select Tree and Order by from another table

    Hi Jeff Moden.

    I'm remove *, from the code and result is:

    A

    --A1

    ----A1.1

    ------Item Code = 3

    --A2

    ----A2.1

    ------Item Code = 1

    ----A2.2

    ------Item Code = 2

    --A3

    B

    C

    But i need result is:

    A

    --A2

    ----A2.1

    ------Item Code = 1

    ----A2.2

    ------Item Code = 2

    --A1

    ----A1.1

    ------Item...

  • RE: Select Tree and Order by from another table

    Thank for you post. But i need result like this:

    A

    --A2

    ----A2.1

    ------Item code = 1

    ----A2.2

    ------Item code = 2

    --A1

    ----A1.1

    ------Item code = 3

    --A3

    B

    C

    Please help/support me.

  • RE: Select Tree and Order by from another table

    ah, My customer make sure: no data like this:

    A

    --A1

    ----A1.1

    --A2

    ----A2.2

    ------Item code = 3

    ------A2.2.1

    --------Item code = 1

    --A3

    B

    --Item code = 2

    C

    Every data input are reasonable.

  • RE: Select Tree and Order by from another table

    For result:

    A

    --A1

    ----A1.1

    ------Beck

    --A2

    ----A2.1

    ------Ronaldo

    ----A2.2

    ------Messi

    --A3

    B

    C

    I have a SQL:

    DECLARE @Folder_Item TABLE(

    IdFolder int,

    FolderName varchar(1024),

    IdFolderParent int,

    ItemCode nvarchar(7)

    )

    INSERT INTO@Folder_Item (

    IdFolder,

    FolderName,

    IdFolderParent,

    ItemCode

    )

    SELECTIdFolder,

    FolderName,

    IdFolderParent,

    '' as ItemCode

    FROMFolders

    UNIONALL

    SELECTIdFolder*10000+ItemCode,

    ItemName,

    IdFolder,

    ItemCode

    FROMItems

    ;WITH FamilyNode AS

    (

    (SELECT Folder.IdFolder,

    Folder.FolderName,

    Folder.IdFolderParent,

    Folder.ItemCode,

    1 AS LevelRoot,

    CAST(ROW_NUMBER()...

  • RE: LEFT JOIN and Smallest

    order by and select top 1

    @The Dixie Flatline: thank you so much

  • RE: Union all fields of tables with conditions

    ColdCoffee (9/6/2010)


    Will tables A, B and C have only one row per table all the time?

    No, may be many have row all the time

    ex:

    A(1,1),B(2,2),B(4,4),C(3,3)

    @CheckA=1,@CheckB=1,@CheckC=1

    Result:

    A1 A2 B1 B2 C1 C2

    1 ...

  • RE: When this SQL error?

    GilaMonster (7/2/2010)


    Don't understand your question. i have a question for you though. Why are you using a cursor?

    I have 2 testcase:

    1: OPEN cursor error

    2: COMMIT error

    But i don't know when...

  • RE: INSERT INTO SELECT WITH ORDER BY

    Híc, i found this solution in http://support.microsoft.com/kb/273586

    It say:

    The following INSERT INTO SELECT FROM query with an ORDER BY clause will guarantee that column ID in NewTable is in...

  • RE: INSERT INTO SELECT WITH ORDER BY

    GilaMonster (6/21/2010)


    Steve Cullen (6/21/2010)


    It really doesn't matter what in order you load the table, you order it on the select out, or use a clustered index.

    There's no OR here. If...

  • RE: INSERT INTO SELECT WITH ORDER BY

    😀 My Flow IS:

    - Truncate table @AAAATABLE

    - INSERT INTO @AAAATABLE from @DATATABLE with ORDER BY V1,V2

    - SELECT * FROM @AAAATABLE ORDER BY K

    I want a result with ordered by V1,V2...

Viewing 15 posts - 1 through 15 (of 68 total)