brocken

  • Has broken group on two subgroups.

    ___________________________________________________________

    1,1111

    2,2222

    3,3333

    4,1111

    5,3333

    ______________________________________________________________

    I whant to see

    ______________________________________________________________

    Variant 1

    subgroups1

    subgroups2 1111 2222 3333

    Variant 2

    subgroups1 1111

    subgroups2 2222 3333

    ...................................................................

  • Just a few points, and one question:

    (1) The code you posted will not execute, please fix it.

    (2) Posting header lines above query results is not done in TSQL, but in the report generator or other user interface. TSQ will only return rowsets with column headings.

    (3) Taking distinct values from several columns and putting them in one column as a result is often accomplished using FOR XML PATH(''). You can search XML CONCATENATION for examples here or look at this article for an example.

    (4) Given the following values from your example, what are the distinguishing characteristics between Variant 1 and Variant 2?

    1,1111

    2,2222

    3,3333

    4,1111

    5,3333

    Thank you. 🙂

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • I have not quite accustomed yet.

    There is a table with repeating names.

    From this table have chosen only unique names.

    These names make set (group) of names.

    This group is broken (divided(shared)) on two subgroups.

    To list all variants of splitting.

    In the given example of them only nine (0110)

  • What you wrote doesn't make sense to us. We can't see the data, and we can't see the rules or results you need. Based on your first post, I'm not sure what rules you are using to great the groups. What you need to do is sit down and type it up in detail, not short sentences. Give us examples of what processing you would like to occur, and why, and then we can help you fix the query.

  • Copy query take advantage SQL Management Studio

    and will see the data.

    Probably, itself I shall execute this query.

    I think, that on a forum should be present the standard test tables, with which help

    explanatories of considered(examined) problems are possible(probable) even.

    Probably, it also is present, but only I do not know it

  • Please show small example of names and subgroups.

    Many of us have the Adventureworks database, as a standard.

    We can't solve your problem without seeing your tables, data and schema.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • First, I'm glad to see that you finally took the time to post your question on SSC instead of attempting to get help via a PM. As you can see several people have responded already, even though it was with more questions.

    Here is the next thing you really need to do. Read the first article I reference below in my signature block about asking for assistance. Follow the instructions in that article and repost your question here in this same thread (don't start a new one for the same problem).

    Sometimes, just going through the setup exercise helps you solve your own problem, or allows you to clarify it better for the rest of us.

  • Thank Lynn.

  • As that so

    DECLARE @pcx TABLE(code int, model varchar(50))

    INSERT INTO @pcx VALUES (1,1111)

    INSERT INTO @pcx VALUES (2,2222)

    INSERT INTO @pcx VALUES (3,3333)

    INSERT INTO @pcx VALUES (4,1111)

    INSERT INTO @pcx VALUES (5,3333)

    DECLARE @pcnm TABLE(numn int,model varchar(50))

    INSERT INTO @pcnm

    select distinct dense_rank() over(order by model)numn,model from @pcx

    select row_number()over(order by set1)variant,set1,set2

    from

    (select set1,

    (select model as 'data()'from @pcnm

    where modelset1

    order by model

    for xml path(''))set2

    from

    (select model set1 from @pcnm)x

    )x

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

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