split data in equal halves

  • Hi,

    I have source data as below. How can i split the data into equal halves and get the other half in the same result.Please suggest

    Column0   Column1
    P-1            A-1
    P-2            A-2
    P-3             A-3

    Output-
    Column0   column1   Column2   Column3
    P-1           A-1             P-3            A-3
    P-2           A-2

    Thanks.

  • Are you talking about NTILE()?
    SELECT BusinessEntityID
        , JobTitle
        , NTILE(4) OVER(ORDER BY BusinessEntityID) AS Quartile
        ,NTILE(2) OVER (ORDER BY BusinessEntityID) AS Half
    FROM HumanResources.Employee;

      so Quartile will divide the set into 4 evenly-sized "chunks" and number them 1-4. You'd just use 2 instead of 4.

  • pietlinden - Friday, February 1, 2019 6:51 PM

    Are you talking about NTILE()?
    SELECT BusinessEntityID
        , JobTitle
        , NTILE(4) OVER(ORDER BY BusinessEntityID) AS Quartile
        ,NTILE(2) OVER (ORDER BY BusinessEntityID) AS Half
    FROM HumanResources.Employee;

      so Quartile will divide the set into 4 evenly-sized "chunks" and number them 1-4. You'd just use 2 instead of 4.

    No i have 2 columns currently with 3 rows. But i want to split those rows equally and have 4 columns as shown above.
    My data is not limited to just 3 rows.

  • Papil - Friday, February 1, 2019 5:17 PM

    Hi,

    I have source data as below. How can i split the data into equal halves and get the other half in the same result.Please suggest

    Column0   Column1
    P-1            A-1
    P-2            A-2
    P-3             A-3

    Output-
    Column0   column1   Column2   Column3
    P-1           A-1             P-3            A-3
    P-2           A-2

    Thanks.

    Can you describe the logic in more details please?
    😎

  • here is an example, splitting the list of all your tables in your current database, into five columns;

    i think you can adapt that to only have four columns, and change the source table to your own from there.

    hope this helps!
    since this is selecting from sys.tables, this should work for anyone as a prototype.
    --select count(*) from sys.tables
    --1573 tables total
    with baseCTE AS (select ROW_NUMBER() over (order by name) As RW,name from sys.tables),
    --the / 25 limits me to 24 rows of 5 accross
      firstCTE AS (select ROW_NUMBER() over (partition by RW / 5 order by name) as RW1, RW,name from baseCTE),
    G1 AS (select ROW_NUMBER() over (order by name) As RW,RW1,name from firstCTE WHERE RW1 = 1),
    G2 AS (select ROW_NUMBER() over (order by name) As RW,RW1,name from firstCTE WHERE RW1 = 2),
    G3 AS (select ROW_NUMBER() over (order by name) As RW,RW1,name from firstCTE WHERE RW1 = 3),
    G4 AS (select ROW_NUMBER() over (order by name) As RW,RW1,name from firstCTE WHERE RW1 = 4),
    G5 AS (select ROW_NUMBER() over (order by name) As RW,RW1,name from firstCTE WHERE RW1 = 5)

    SELECT
    G1.name,
    G2.name,
    G3.name,
    G4.name,
    G5.name
    FROM G1
    LEFT OUTER JOIN G2 ON G1.RW = G2.RW
    LEFT OUTER JOIN G3 ON G1.RW = G3.RW
    LEFT OUTER JOIN G4 ON G1.RW = G4.RW
    LEFT OUTER JOIN G5 ON G1.RW = G5.RW

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Eirikur Eiriksson - Saturday, February 2, 2019 6:05 AM

    Papil - Friday, February 1, 2019 5:17 PM

    Hi,

    I have source data as below. How can i split the data into equal halves and get the other half in the same result.Please suggest

    Column0   Column1
    P-1            A-1
    P-2            A-2
    P-3             A-3

    Output-
    Column0   column1   Column2   Column3
    P-1           A-1             P-3            A-3
    P-2           A-2

    Thanks.

    Can you describe the logic in more details please?
    😎

    Sorry for confusion.Here is DDL for input and output.

    Splitting the data equally. If there are 3 rows. First two columns have 2 rows and next two column has 1 row and NULL. This example has only 3 rows. My table has more.

    Input-
    CREATE TABLE mytable1(
     Column0 VARCHAR(3) NOT NULL PRIMARY KEY
    ,Column1 VARCHAR(3) NOT NULL
    );
    INSERT INTO mytable1(Column0,Column1) VALUES ('P-1','A-1');
    INSERT INTO mytable1(Column0,Column1) VALUES ('P-2','A-2');
    INSERT INTO mytable1(Column0,Column1) VALUES ('P-3','A-3');

    Output-
    CREATE TABLE mytable(
     Column0 VARCHAR(3) NOT NULL PRIMARY KEY
    ,column1 VARCHAR(3) NOT NULL
    ,Column2 VARCHAR(4)
    ,Column3 VARCHAR(4)
    );
    INSERT INTO mytable(Column0,column1,Column2,Column3) VALUES ('P-1','A-1','P-3','A-3');
    INSERT INTO mytable(Column0,column1,Column2,Column3) VALUES ('P-2','A-2',NULL,NULL);

  • Papil - Saturday, February 2, 2019 7:14 PM

    Eirikur Eiriksson - Saturday, February 2, 2019 6:05 AM

    Papil - Friday, February 1, 2019 5:17 PM

    Hi,

    I have source data as below. How can i split the data into equal halves and get the other half in the same result.Please suggest

    Column0   Column1
    P-1            A-1
    P-2            A-2
    P-3             A-3

    Output-
    Column0   column1   Column2   Column3
    P-1           A-1             P-3            A-3
    P-2           A-2

    Thanks.

    Can you describe the logic in more details please?
    😎

    Sorry for confusion.Here is DDL for input and output.

    Splitting the data equally. If there are 3 rows. First two columns have 2 rows and next two column has 1 row and NULL. This example has only 3 rows. My table has more.

    Input-
    CREATE TABLE mytable1(
     Column0 VARCHAR(3) NOT NULL PRIMARY KEY
    ,Column1 VARCHAR(3) NOT NULL
    );
    INSERT INTO mytable1(Column0,Column1) VALUES ('P-1','A-1');
    INSERT INTO mytable1(Column0,Column1) VALUES ('P-2','A-2');
    INSERT INTO mytable1(Column0,Column1) VALUES ('P-3','A-3');

    Output-
    CREATE TABLE mytable(
     Column0 VARCHAR(3) NOT NULL PRIMARY KEY
    ,column1 VARCHAR(3) NOT NULL
    ,Column2 VARCHAR(4)
    ,Column3 VARCHAR(4)
    );
    INSERT INTO mytable(Column0,column1,Column2,Column3) VALUES ('P-1','A-1','P-3','A-3');
    INSERT INTO mytable(Column0,column1,Column2,Column3) VALUES ('P-2','A-2',NULL,NULL);

    A little simple arithmetic and a CROSS TAB is all that's needed to solve this problem.

       WITH cte AS
    (
     SELECT  RN = (ROW_NUMBER() OVER (ORDER BY Column0, Column1)-1)/2
            ,CN = (ROW_NUMBER() OVER (ORDER BY Column0, Column1)-1)%2
            ,*
       FROM #mytable1
    )
     SELECT  Column0 = MAX(CASE WHEN CN = 0 THEN Column0 ELSE NULL END)
            ,Column1 = MAX(CASE WHEN CN = 0 THEN Column1 ELSE NULL END)
            ,Column2 = MAX(CASE WHEN CN = 1 THEN Column0 ELSE NULL END)
            ,Column3 = MAX(CASE WHEN CN = 1 THEN Column1 ELSE NULL END)
       FROM cte
      GROUP BY RN
    ;

    Results...
    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVsAAABeCAYAAACNdbfqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABHNSURBVHhe7Z0PbBRXfse/RFGiSrlWlVpdacEmyKZRCsSKqQqYPyFCcSAgBZ0hKSTnJirrUNHDls7iciARS05Vyz0ZklTEa13zhzh3AUskAuwQUf5jkhaujnEQwauEgFMu4nq6S4hU6HHue2/ezM7au7Mzs7OLZ+b7QY9582Zn7fn5zXd+7zcz7zdpaODD0Z5330fd449CLv1w9OhRvLL9n33vTwghUccSWymYhBBCioMltoQQQoqHEltdJ4QQUiTu0EtCCCFFhGJLCCElgGJLCCElICNm+1cP/I2uEZNPPv5I1wghxD+W2EqhpbCMZ2Pjj9QzxIQQUghKbCm0uZGPxW3btk2vEa+wXxFiQLHNg/nCB71bf3BkQIiBa7F96aM7dS07Z8/qyhje+Iff6Vo4cRLbX/3mf9Xy66+/Vks7v/7115hTVaHX4os5MuDFnMQdT08jVFdXp4v4J1qskrFNl6jz6af3YPHixVi5cmVGmTt3LvpvfKs/RZYsWaJrhMQXT2J7VrivVhH/REtm25iiPuLElXfwVNVczBxTWk7q7YUiv//77+CyXi0m0rs9+z/ikEU5dOmu/MdOCIkVrsVW+qmdiWqrrH9wVC3PdBrlJ2uvW/VTL82E2CRIyv+cmd2E3oEPMWSWfU0YTgYskEUW3QsXLmB4eBijn5/Bxc9+i2/+K6W3EEKIge+XGr79NnOYbMYtb9y4oYrkrrvOqaUnppahcvASvtCrE52k8OCl0EpH/pNPPsXN8/tx990X9FYfmN5+62ndIBnBru+LthJ56YSQ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SHFwZXYhvmKZeYgC/MxlAJ6Js4Y9onXW4Ve+OTjq7SPA4Z9YpKDjELiDMXWGYqtMxRbZ0yxjcXTCIQQcrvxLbaXu9erWJ9VWk/rLTGkryH9CqEsfAV1PLQRiTn+PdvyZ9E7oFPj7GtCVU8Tnuoe0RtDhJy2zS4CqnjMH1XZnM6PJCfY6G9EfSTnci0gh1SkbXQEDZPKkfmqvmx73pjVKvVvoo+N2a7aHLbbybd9wkP7SHyLbdmCeSjTdUytQe1sYODzCZxiNw+F5I+SOV/Ss75V4v75uho1CsghFQcbJZdrcSBZibt9Ao3ZVt0bosRkOSkwf5QSpPkq/UfUCCyHVGRt9DZad8QrpZI34m2fYMT2ZDfaBlehYd0U3RBu/OSPstJ6RHSmfTlNYqE5pKJto7Xo7V0r7NJJ7zYrtE/hYnvlHTy1MYXN+zZjoW4KNSl/+aOstB7Da7C7MoL5twLIIRV5Gy1rwPb59G5zEnP7FCa2UmhXHkLtvi48HfIIQsH5o0wqNkFFIXYfiNTd9kBzkEXURsA0bHpjG0DvNgfxtk8BYjuCXVs6UPlK+IVWUlj+qEwqI3f3J/gcZNGzkabiWXEheRvLGz7QDYKKezFTV2NPjO3jW2wvd7egDU14ZoFuIAZmGGLNY7a77yEn6BxkUbSRjWWdryORfFtYx2SJHgkc0evCBAf2oz/xiBWqihNxtY9PsR3BsYPngMEOLOeLDUKMbA/sVzaKTtJbsHc8cQgih5Qg0jYayxI0b6/WdYNlncewfejvxPGXq1K5ewWGO5forQbJ5ca2dMl8VCrf9vAQT/twbgSi3/2njXLBuRGc4dwIznBuBEIIKSEUW0IIKQEUW0IIKQGuYrZhz0HGeKQzjNk6w5itM4zZOmPGbPOKbRRykFFInKHYOkOxdYZi64xrsSWEEOIf05FxFNsjR9IPGRNCCPEPb5ARQkjRAf4fUdelNIHyhfIAAAAASUVORK5CYII=

    I say "simple" because if you really want the items in Column0/Column1 to be  exhausted in order prior to the order resuming in Column2/Column3, that'll take a bit more.  Let us know if you actually need it that way.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Never mind... I did it the other way, too.

    -- DROP TABLE #MyHead
    --==========================================================================
    --      Create the test data
    --      (This is NOT a part of the solution)
    --==========================================================================
     CREATE TABLE #MyHead
            (
              Column0 VARCHAR(3) NOT NULL PRIMARY KEY
             ,Column1 VARCHAR(3) NOT NULL
            )
    ;
     INSERT INTO #MyHead(Column0,Column1)
     VALUES  ('P-1','A-1')
            ,('P-2','A-2')
            ,('P-3','A-3')
            ,('P-4','A-4')
            ,('P-5','A-5')
            --,('P-6','A-6') --Just a test for an even number of items
    ;
    --==========================================================================
    --      Create the display where column set #1 is exhausted by sort order
    --      and is continued into column set #2.
    --==========================================================================
       WITH
     cteColumnSets AS
    (--==== Enumerate the column "sets"
     SELECT CN = NTILE(2) OVER (ORDER BY Column0, Column1)
            ,*
       FROM #MyHead
    )
    ,cteRowSets AS
    (
    --==== Enumerate the row "sets"
     SELECT RN = ROW_NUMBER() OVER (PARTITION BY CN ORDER BY Column0,Column1)
            ,*
       FROM cteColumnSets
    )
     SELECT  Column0 = MAX(CASE WHEN CN = 1 THEN Column0 ELSE NULL END)
            ,Column1 = MAX(CASE WHEN CN = 1 THEN Column1 ELSE NULL END)
            ,Column2 = MAX(CASE WHEN CN = 2 THEN Column0 ELSE NULL END)
            ,Column3 = MAX(CASE WHEN CN = 2 THEN Column1 ELSE NULL END)
       FROM cteRowSets
      GROUP BY RN
    ;

    Results:
    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVsAAABsCAYAAADExxFMAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABPYSURBVHhe7Z0PbFRH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WYCKt93Iut9aGG9S0YqGrB29U6zEZwgXXCflEt6yTdGmVXzUEOKe1slM5q1LeWyrrB2rYzaB3+ETv+AlGKDq3DSNtqudcgVmnsS5bUqVLZ9geHcNqH1kYg5LP/ZKOpoLUR1NDaCGpobQSCIIhphMSWIAhiGiCxJQiCmAZsxWwpB5neUMxWDcVs1VDMVo0Zs80qtpSDTH9IbNWQ2KohsVVjW2wJgiAI95iOjFJsT51KTjImCIIg3AL8P2i0I9l9a5laAAAAAElFTkSuQmCC

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks .It works.

  • Papil - Monday, February 4, 2019 7:10 AM

    Thanks .It works.

    To be sure, do you understand how and why it works?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply