Group, sum and total.

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Fri, 11 Jun 2004 11:15 am

Want to add a value for each group but also want to receive the TOTAL of everything in the same query. You can?

Something like this:
Code: Select all
AAA    50
BB     30
total  80
tfg
Location: Novo Hamburgo - RS

Poston Fri, 11 Jun 2004 12:52 pm

Groups, account and still gives the total is in the USER SCOTT ...

Code: Select all
SELECT
  DECODE(GROUPING(DEPTNO),1,'TOTAL----->',DEPTNO) DEPTNO,
  COUNT(*) QTD
FROM EMP
GROUP BY ROLLUP(DEPTNO)
/


DEPTNO                               QTD
--------------------------------- ----------
20                                      4
30                                      6
50                                      1
TOTAL----->                            11
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered



Return to SQL

Who is online

Users browsing this forum: No registered users and 4 guests