Bonjour, je me remet doucement dans le SQL et je ne comprend pas pourquoi cette requête ne fonctionne pas.

Requête qui fonctionne :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
select (case when origine_typeopcom='PCN' or origine_typeopcom='MAJ' then ORIGINE_LIBOPCOM else 'MANUEL' end) as Motif,
DATE_MAJ_CAISSE
from CAISSE.CHGT_PRIX
where date_MAJ_CAISSE >='2018-09-19' and date_MAJ_CAISSE <='2018-11-15'
Mais j'ai plusieurs fois le même Motif, à la même Date_Maj_caisse, je souhaite donc utiliser count(*) pour les regrouper et avoir un tableau plus lisible. C'est là que je bloque :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
select (case when origine_typeopcom='PCN' or origine_typeopcom='MAJ' then ORIGINE_LIBOPCOM else 'MANUEL' end) as Motif,
DATE_MAJ_CAISSE, count(*)
from CAISSE.CHGT_PRIX
where date_MAJ_CAISSE >='2018-09-19' and date_MAJ_CAISSE <='2018-11-15'
group by DATE_MAJ_CAISSE,(case when origine_typeopcom='PCN' or origine_typeopcom='MAJ' then ORIGINE_LIBOPCOM else 'MANUEL' end) as Motif
ça me renvoi :
Error: ILLEGAL SYMBOL as; VALID SYMBOLS ARE M else 'MANUEL' end). .. (State:37000, Native Code: FFFFFF98)
Error: An error occurred during implicit system action type '2'. Information returned for the error includes SQLCODE '-104', SQLSTATE '42601' and message tokens 'as|M else 'MANUEL' end)|..'. (State:56098, Native Code: FFFFFD29)

Merci d'avance.

ImuraDarling