Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

Challenging T-SQL Query

$
0
0

I am using SQL Server 2008

My data looks like this

name id  data
==== ===  =====
cxyz 2  coffee
jojo 3  barley
moto 4  jasmine
samie 1  elda
dunk 2  tarmal
sihoo 3  newcome
iblie 2  acost
samou 17  ikea

I want the resultset in n groups like show below;(basically groups are bundled based on 2 and 1s)

name id  data
==== ===  =====
cxyz 2  coffee
jojo 3  barley
moto 4  jasmine

name id  data
==== ===  =====
samie 1  elda

name id  data
==== ===  =====
dunk 2
tarmal
sihoo 3  newcome

name id  data
==== ===  =====
iblie 2  acost
samou 17  ikea


Thanks a lot


SV



Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>