|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Nov 2000
Città: Salerno
Messaggi: 4338
|
[MYSQL] "unire" DISTINCT e GROUP BY
Salve raga
allora, ho il seguente problema... Su una tabella del genere TIPO | NOME | TOT ------------------------- a tizio 10 a tizio 20 b tizio 15 vorrei ottenere il seguente risultato TIPO | NOME | TOT ------------------------- a tizio 30 b tizio 15 Quindi raggruppare per nome ma con il tipo distinto... Come potrei ovviare? Thanks
__________________
Doc : "Ovviamente, il continuum temporale è stato interrotto creando questa nuova temporale sequenza di eventi risultante in questa realtà alternativa" Marty : ...
|
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
doppio. vedi sotto
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele Ultima modifica di marco.r : 29-07-2012 alle 14:24. |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
Quote:
Cmq non ho capito, per ottenere quel che hai descritto ti basta fare un group by sulla singola colonna... o no ? Codice:
select tipo,nome,sum(tot) from my_table group by tipo
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele |
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Nov 2000
Città: Salerno
Messaggi: 4338
|
Scusami, hai ragione... L'esempio non è chiaro in quanto al tipo posso appartenere anche altri nomi...
TIPO | NOME | TOT ------------------------- a tizio 10 a tizio 20 b tizio 15 a roma 30 b roma 50 b roma 40 Quindi TIPO | NOME | TOT ------------------------- a tizio 30 b tizio 15 a roma 30 b roma 90
__________________
Doc : "Ovviamente, il continuum temporale è stato interrotto creando questa nuova temporale sequenza di eventi risultante in questa realtà alternativa" Marty : ...
|
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
allora tu vuoi raggruppare in base alla coppia (tipo,nome).
Prova con "GROUP BY tipo,nome"
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele |
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Nov 2000
Città: Salerno
Messaggi: 4338
|
Sorry... Era così facile
Thanks
__________________
Doc : "Ovviamente, il continuum temporale è stato interrotto creando questa nuova temporale sequenza di eventi risultante in questa realtà alternativa" Marty : ...
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 10:36.




















