Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 to optimize query

Author  Topic 

abc
Starting Member

48 Posts

Posted - 2001-11-14 : 06:15:42
Hello, if I have two queries are return the same result sets
example:

Fist query have where clause:

SELECT pub_id, SUM(advance) AS AmountAdvanced,

AVG(price) AS AveragePrice

FROM pubs.dbo.titles

WHERE pub_id > '0800'

GROUP BY pub_id

HAVING SUM(advance) > $15000

AND AVG(price) < $20

Second query (have no where clause, the condition is used in having clause)

SELECT pub_id, SUM(advance) AS AmountAdvanced,

AVG(price) AS AveragePrice

FROM pubs.dbo.titles

GROUP BY pub_id

HAVING SUM(advance) > $15000

AND AVG(price) < $20

AND pub_id > '0800'

I want to use the one optimizer than the other. But I don't know wich one should I select. So could you tell me the way (in commond) to determind wich query otimizer than other


Thanks for your attention
   

- Advertisement -