declare @Nomination table ( NominationID int ) insert i...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Anime and Manga

Q&A for anime and manga fans

-- Enter Query Title
-- Enter Query Description

declare @Nomination table
(
  NominationID int
)

insert into @Nomination values(19)

declare @NominationAwardFocus table
(
  AwardFocusID int,
  NominationID int
)

insert into @NominationAwardFocus values
(5, 19),
(7, 19),
(8, 19)

declare @AwardFocus table
(
  AwardFocusID int,
  AwardFocusName nvarchar(10)
)

insert into @AwardFocus values
(1, 'Name 1'),
(2, 'Name 2'),
(3, 'Name 3'),
(4, 'Name 4'),
(5, 'Name 5'),
(6, 'Name 6'),
(7, 'Name 7'),
(8, 'Name 8'),
(9, 'Name 9')

select stuff((select ', '+AF.AwardFocusName
              from @AwardFocus as AF
                inner join @NominationAwardFocus as NAF
                  on AF.AwardFocusID = NAF.AwardFocusID
              where N.NominationID = NAF.NominationID
              for xml path(''),  type).value('.', 'nvarchar(max)'), 1, 2, '') as AwardFocusNames
from @Nomination as N

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results