title: How to get this query with the use of extended group by functions
body: <p>I am trying to write a query that returns this:</p>
  
  <pre><code>DNAME                                    G TITLE            SALARY
  ---------------------------------------- - ------------ ----------
                                                             1059000
                                             Analyst          107000
                                             Manager          395000
                                             Developer        152000
                                             Programmer       152500
                                             Sr. Analyst      252500
                                           F                  366500
                                           M                  692500
  Risk and Compliance                                         264500
  Finance and Accounting Excellence                           395000
  Internal Audit and Financial Controls                       399500
  
  11 rows selected.
  </code></pre>
  
  <p><strong>UPDATE!!!</strong> Ok so I was playing around with different queries and this is the closest I have to the above output...it looks like its still missing the sum of all salaries for the first returned row...and I believe in order to make the generated output to display in that format is through the use of the group by cube function however I've tried different combinations of group by group sets cube to no avail...any ideas???</p>
  
  <blockquote>
    <p>select dname, gender, title, salary from (select dname, gender, title,
    grouping_id(dname, gender, title) as "group_id", sum(salary) as salary from azdepartment 
    join azconsultant on azdepartment.did=azconsultant.did group by grouping sets(dname, 
    gender, title) having grouping_id(dname, gender, title)>0);</p>
  </blockquote>
  
  <pre><code>DNAME                                    G TITLE            SALARY
  ---------------------------------------- - ------------ ----------
                                             Manager          395000
                                             Programmer       152500
                                             Sr. Analyst      252500
                                             Analyst          107000
                                             Developer        152000
  Finance and Accounting Excellence                           395000
  Risk and Compliance                                         264500
  Internal Audit and Financial Controls                       399500
                                           M                  692500
                                           F                  366500
  
  10 rows selected.
  </code></pre>