Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Conversion
Message
De
29/09/2011 19:23:40
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
01525186
Message ID:
01525214
Vues:
35
CASE doesn't work. It returns me to the original error demanding receiveddate and amount be included in the group by clause.

>CASE would be more efficient than subqueries
>
>>OK. Not sure if this is the best solution but it seems to work.
>>select [fisyear], [category], 
>>(select [amount] from [RTA-Revenues] where (MONTH(receiveddate)=7 and CATEGORY=crsA.CATEGORY and FISYEAR=crsA.fisyear)) as jul,
>>(select [amount] from [RTA-Revenues] where (MONTH(receiveddate)=8 and CATEGORY=crsA.CATEGORY and FISYEAR=crsA.fisyear)) as aug,
>>(select [amount] from [RTA-Revenues] where (MONTH(receiveddate)=9 and CATEGORY=crsA.CATEGORY and FISYEAR=crsA.fisyear)) as sep
>>from [rta-revenues] as crsA
>>group by [fisyear],[category]
>>order by FISYEAR, CATEGORY
>>
>>Note it does not use the CASE statement we had been playing with. What I don't understand is why the former did not work and why it insisted on having receiveddate in the group by clause, since it was not actually in the select list. It was just included in a function within the select list. Oh well, thanks for your help. As always, you made me think.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform