Today one of my colleagues, Saivendra Kayal, posed a problem and wondered if it could be solved in T-SQL.
He wanted to turn a set of data that looks like this:

into this:

There's one proviso though. The solution can't contain any procedural logic. So no variables, no cursors, and it has to be one single SQL statement. CTEs are OK. To put it another way, it has to be something you can put into a view definition.
I managed to come up with a fairly elongated solution but then Saivendra trumped me with a much more concise one. I'll post those in my next post but in the meantime, have a go and see if you can solve it. I'm going away for a couple of days (to Las Vegas
) so you've got a while to come up with an answer.
Here's a script that produces the sample data:
USE tempdb
GO
CREATE TABLE t1 (id INT, NAME VARCHAR(MAX))
INSERT t1 values (1,'Jamie')
INSERT t1 values (1,'Joe')
INSERT t1 values (1,'John')
INSERT t1 values (2,'Sai')
INSERT t1 values (2,'Sam')
-Jamie