You are here: Re: looking to tune query... « MsSQL Server « IT news, forums, messages
Re: looking to tune query...

Posted by blvandeb@yahoo.com on 09/15/06 20:09

AMAZING...THANK YOU SO MUCH!

Razvan Socol wrote:
> The above query should provide the same results as your query with a
> DISTINCT clause, but is shorter and should perform better:
>
> SELECT id, Advisement_Satisfaction_yes, Advisement_Satisfaction_NO,
> CASE
> WHEN Advisement_Satisfaction_yes>Advisement_Satisfaction_NO
> THEN 'YES'
> WHEN Advisement_Satisfaction_yes<Advisement_Satisfaction_NO
> THEN 'NO'
> ELSE 'TIE'
> END AS Satisfied_With_Advisement
> FROM (
> SELECT id,
> SUM(CASE WHEN answer_text='yes' THEN 1 ELSE 0 END)
> AS Advisement_Satisfaction_yes,
> SUM(CASE WHEN answer_text='NO' THEN 1 ELSE 0 END)
> AS Advisement_Satisfaction_NO
> FROM a GROUP BY id
> ) x
>
> Razvan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация