Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Inserting Space when a Break Column's Value Changes

Posted on 2012-04-09
3
Medium Priority
?
262 Views
Last Modified: 2012-04-10
Hi,

I want to insert a space when a column's value changes in SQL

ID        LAST_NAME                     SALARY
------------- ------------------------- ----------
20         Hartstein                      13000

80         Russell                           14000
              Partners                       13500

90          King                               24000
              Kochhar                        17000
0
Comment
Question by:VenkatBunny
3 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 37825150
You should use a reporting tool such as SSRS to achieve that.
0
 

Author Comment

by:VenkatBunny
ID: 37826051
Is there Anyway to group the ID by not displaying the ID in MS SQL

ID        LAST_NAME                     SALARY
------------- ------------------------- ----------
20         Hartstein                      13000
80         Russell                           14000
              Partners                       13500
90          King                               24000
              Kochhar                        17000
0
 
LVL 18

Accepted Solution

by:
deighton earned 450 total points
ID: 37827573
SELECT case when rowx = 1 then cast(tt.id as nvarchar(10)) else '' end, tt.Last_name, tt.salary FROM  (select id,last_name,salary,row_number() over (partition by id order by salary) as rowX from YourTable) tt
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question