Skip to content

Instantly share code, notes, and snippets.

@ysinc88
Created December 18, 2015 12:30
Show Gist options
  • Save ysinc88/363eb0f39810a3afd5bd to your computer and use it in GitHub Desktop.
Save ysinc88/363eb0f39810a3afd5bd to your computer and use it in GitHub Desktop.
tsql concat
select
r.name as release,a.name as artist,r.version,l.name as label,count(distinct r.upc) as upcCount,concat(distinct r.upc) as upcs
from releases r
join artists a on a.artistid = r.artistid
join labels l on l.labelid = r.labelid
where l.name = 'foo'
group by r.name, a.name,l.name,r.version,upcs
having count(distinct r.upc) > 1
order by upcCount desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment