Using pubs I need to find titles that have exactly 2 authors and display the results like this
[title][author1][author2]
title1 author1 author2
I have a query that returns in this format
[title][author]
title1 author1
title1 author2
select t.title, a.au_lname from titles t
inner join titleauthor ta on t.title_id = ta.title_id
inner join authors a on ta.au_id = a.au_id
where t.title_id in(select title_id from titleauthor
group by title_id
having count(au_id) = 2)
I don't want to use dynamic sql, cursors. It must be pure sql.
Thanks,
Jon
[title][author1][author2]
title1 author1 author2
I have a query that returns in this format
[title][author]
title1 author1
title1 author2
select t.title, a.au_lname from titles t
inner join titleauthor ta on t.title_id = ta.title_id
inner join authors a on ta.au_id = a.au_id
where t.title_id in(select title_id from titleauthor
group by title_id
having count(au_id) = 2)
I don't want to use dynamic sql, cursors. It must be pure sql.
Thanks,
Jon