Ordinare per totali

nove9nove

Nuovo Utente
20 Ott 2008
1
0
0
Ciao ragazzi, ho un problema con un report.

Ho 4 campi

1 - Codice cliente
2 - Numero Fattura
3 - Data Fattura
4 - Importo

Devo creare un report che elenchi, raggruppato per cliente, tutte le fatture relativo ad un dato cliente, sommando il totale per mese...e fin qui tutto bene. Il problema è che l'elenco dei clienti deve essere ordinato in base al credito aperto...
vi incollo le mie due query

Per ottenere il totale per cliente
SELECT Teleriscaldamento.[Codice Cliente], Sum(Teleriscaldamento.Valore) AS SumOfValore
FROM Teleriscaldamento
GROUP BY Teleriscaldamento.[Codice Cliente]
ORDER BY Sum(Teleriscaldamento.Valore) DESC;


Fatture del primo trimestre
SELECT Teleriscaldamento.[Numero Fattura], Teleriscaldamento.[Data Fattura], Teleriscaldamento.[Data di Pagamento], Teleriscaldamento.[Data Scadenza], Teleriscaldamento.Valore, Teleriscaldamento.[Codice Cliente], Teleriscaldamento.[Metodo Pagamento], Teleriscaldamento.[Frequenza Fatturazione], Teleriscaldamento.[Periodo Fatturazione], Teleriscaldamento.[Gruppo Lavorazione]
FROM Teleriscaldamento
WHERE ([Teleriscaldamento].[Data Fattura] between #01/01/2007# and #31/12/2007# );
 

Discussioni simili