Top in Join

  • Hey,

    I'll be short : Can I use "top" inside "join" ?

    If not, what's my alternative ?

    Yaniv

  • yes u can, and here is an example:

    select top 100 *

    from strings_sort_06 S left join

    (select display_string, sortKey as sk, attribute_id from EST05.dbo.Strings_Sort_05) t2

    on s.display_string = t2.display_string AND S.attribute_id = t2.attribute_id

    where S.attribute_id = 7009

    --returns 100 recs

  • and another depending on a different requirement...

    use pubs
    go
    
    select au_fname + ' ' + au_lname as authorName, title
    from dbo.authors a
    inner join (select top 3 au_id, title_id from dbo.titleauthor)ta on a.au_id = ta.au_id
    inner join dbo.titles t on ta.title_id = t.title_id
    order by authorName
    







    **ASCII stupid question, get a stupid ANSI !!!**

  • Thanks.

    Yaniv

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply