SQL for Smarties | SQL Programming Style | Trees and Hierarchies in SQL | SQL Puzzles and Answers | Data and Databases


Tuesday, June 12, 2007

add blank row between groups of rows to separate them?

SQL Apprentice Question
I want to add a blank row between groups of rows to separate them.


select * from tbl1 where fname in ('Bill', 'tom', 'sam')


returns


Bill, 1, 2, 3
bill 4, 5, 6
tom, 1, 2, 3
tom, 4, 5, 6
sam, 1, 2, 3
sam, 4, 5, 6


I want to return this:


Bill, 1, 2, 3
bill 4, 5, 6


tom, 1, 2, 3
tom, 4, 5, 6


sam, 1, 2, 3
sam, 4, 5, 6


How can I perform this type of operation with tsql?



Celko Answers
>> How can I perform this type of operation with tsql? <<


Why are you formatting data in the back end? The basic principle of a
tiered architecture is that display is done in the front end and never
in the back end. This a more basic programming principle than just
SQL and RDBMS.

Original Source

1 comment:

Tim H said...

Lazy Answer. Sometimes, as SQL programmer you are asked to run a query for someone, it is helpful to format the returning results set. Not everything is run through a Front End.