-- XPATH QUERY - issues by issue type and day
SELECT ISSUE,STUFF((SELECT ', ' + convert(varchar(10),T2.N) + '('+ convert(varchar(3),y)+')'
FROM pix001_issues AS T2 WHERE T2.issue = T1.issue order by y desc
FOR XML PATH ('')), 1, 2,'') AS N
FROM pix001_issues AS T1
group by issue
order by ISSUE
/*
declare @a varchar(8000)
SELECT @a = COALESCE(@a + ',', '') +
CAST(N AS varchar(50))
FROM pix001_issues where issue= 302013 order by y desc
print @a
*/
-- select * from pix001_issues where issue=105006
Result:
ISSUE N
104004 1(192), 1(140)
105003 1(192), 6(191), 1(140), 6(100)
105004 1(192), 6(191), 1(140), 6(100)
105005 1(196), 1(192), 2(176), 1(175), 1(157), 1(141), 1(107), 1(105), 1(81), 1(73), 1(54), 1(35)
No comments:
Post a Comment