Now Do You Break The Data When Using A Group By Clause

  • Hi Folks

    I cannot figure out what I need to do in my T-SQL to break the data

    Example output:

    Project-1 Name-1

    Project-1 Name-2

    Project-1 Name-3

    Project-2 Name-4

    Project-2 Name-5

    Project-2 Name-6

    I would like to see;

    Project-1 Name-1

    Name-2

    Name-3

    Project-2 Name-4

    Name-5

    Name-6

    Can this be accomplished in T-SQL

    Thanks

    Jim

  • The current output looks straight forward in terms of a table output. You have two columns with the corresponding values.

    It seems like your question is more related to a reporting issue.

    For such a scenario you could use ROW_NUMBER() to provide an additional column holding the information when to show the first column (row_number=1 for each project). You could even use T-SQL to replace the value in the project column with '' for rows with row_number<>1.

    If you'd like to see the coded version please provide ready to use sample data as described in the first l ink in my signature.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • That kind of data formatting is usually done in the report or application it's being presented in. Most allow for that kind of thing pretty easily. Don't do it in T-SQL, do it in the presenation layer.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 3 posts - 1 through 2 (of 2 total)

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