Re: problema con query!!!
Ciao prova con questa query:
SELECT O.Contatto_idContatto, CAST(SUM(IF(T.descrizione='Acquisto',-chf,chf)) AS SIGNED) AS chf_sum , CAST(SUM(IF(T.descrizione='Acquisto',-euro,euro)) AS SIGNED) AS euro_sum
FROM Operazione O, Tipo T
WHERE O.Tipo_idTipo=T.idTipo GROUP BY O.Contatto_idContatto
praticamente tramite l'IF tramuti in negativo i valori di chf e di euro e li sommi col SUM, la funzione di CAST serve a rendere il risultato in formato numerico, perchè altrimenti quello che verrebbe fuori da IF viene interpretato come testo anche se il SUM comunque procede con l'operazione.
Ciao
Maurizio
Subject
Views
Written By
Posted
4216
September 02, 2007 05:47AM
Re: problema con query!!!
3032
September 04, 2007 02:54AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.