|
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]
|