# Pastebin 6Y3gAUex WITH recording_tags AS ( SELECT recording_mbid , tag_count , 'recording' FROM tags.tags WHERE tag = :tag AND source = '' AND begin_percent <= percent AND percent < end_percent ORDER BY tag_count DESC LIMIT :limit OFFSET :offset ), artist_tags AS ( SELECT recording_mbid , tag_count , source FROM tags.tags WHERE tag = :tag AND source = 'artist' AND begin_percent <= percent AND percent < end_percent ORDER BY tag_count DESC LIMIT :limit OFFSET :offset ), release_tags AS ( SELECT recording_mbid , tag_count , source FROM tags.tags WHERE tag = :tag AND source = 'release-group' AND begin_percent <= percent AND percent < end_percent ORDER BY tag_count DESC LIMIT :limit OFFSET :offset ) SELECT * FROM recording_tags UNION ALL SELECT * FROM artist_tags UNION ALL SELECT * FROM release_tags ORDER BY tag_count DESC