Re: Help needed with subqueries.
From: Jacco Schalkwijk (jacco.please.reply_at_to.newsgroups.mvps.org.invalid)
Date: 06/28/04
- Next message: Jacco Schalkwijk: "Re: Update problem"
- Previous message: Roji. P. Thomas: "Re: Update problem"
- In reply to: Roji. P. Thomas: "Re: Help needed with subqueries."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 28 Jun 2004 13:50:49 +0100
TOP 100 Percent with an ORDER BY clause is meaningless, and can hinder
performance. The set that is returned by the subquery is treated like a view
or a table, which means that it is thought of as being unordered. Only when
you use TOP ... ORDER BY to limit the number of rows returned by the
subquery does it have any meaning.
-- Jacco Schalkwijk SQL Server MVP "Roji. P. Thomas" <lazydragon@nowhere.com> wrote in message news:%23dW1jmQXEHA.1036@TK2MSFTNGP10.phx.gbl... > 1. It works if you specify an alias for the subquery. > Right > 2. TOP 100 percent is needed if the subquery contains an ORDER BY clause. > An ORDER BY clause in a subquery is meaningless, If you are not using > TOP. > > -- > Roji. P. Thomas > SQL Server Programmer > "Strange Cat" <strange@cat.com> wrote in message > news:gOTDc.542881$rM4.22678060@news4.tin.it... > > [CUT] > > > > Thanx to everyone answering! > > > > I would have spent a month searching for the answer... my SQL skills are > > limited (to be fair to myself...). > > > > It actually appears that: > > > > 1. It works if you specify an alias for the subquery. > > 2. TOP 100 percent is needed if the subquery contains an ORDER BY clause. > > > > Working sample: > > SELECT * FROM (SELECT TOP 100 percent * FROM T26ComDipendenti LEFT JOIN > > T28ComGruppiDip ON T26ComDipendenti.T26Gruppo = T28ComGruppiDip.T28Codice > > ORDER BY T26Cognome, T26Nome) AS Risultati WHERE (T26Codice='00000001') > > > > Thanx again to all of you! > > > > Have a nice day > > > > ASC > > > > > > > >
- Next message: Jacco Schalkwijk: "Re: Update problem"
- Previous message: Roji. P. Thomas: "Re: Update problem"
- In reply to: Roji. P. Thomas: "Re: Help needed with subqueries."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|