Home » Open Source » MySQL » Names along with sum(sal) (MySQL)
Names along with sum(sal) [message #646613] Tue, 05 January 2016 10:04 Go to next message
Danny Freeman
Messages: 11
Registered: December 2015
Location: UK
Junior Member
Hello all,

I just want to know that Can I display deptno without grouping along with sum(sal)from emp table ? I mean I want to show the deptno without grouping them but I also want to show the Sum(sal). The sum of salary should be displayed in only first row.

SELECT deptno,
Sum(sal)
FROM emp
GROUP BY deptno;

I know the output of above query. But I want to show all the deptno. I don't want to aggregate deptno but at the same time I want to sum(sal)and its sum should be displayed in first row only. The output should be like this:
Deptno Sum(sal)
10 15000
20
30
40
20
30
10
20

Re: Names along with sum(sal) [message #646614 is a reply to message #646613] Tue, 05 January 2016 10:11 Go to previous messageGo to next message
BlackSwan
Messages: 25745
Registered: January 2009
Location: SoCal
Senior Member
>Names along with sum(sal) (MySQL)
MYSQL? Really?
This forum is dedicated to Oracle RDBMS; not MYSQL.
consider http://forums.mysql.com instead
Re: Names along with sum(sal) [message #646615 is a reply to message #646614] Tue, 05 January 2016 10:14 Go to previous messageGo to next message
Danny Freeman
Messages: 11
Registered: December 2015
Location: UK
Junior Member
Sir, I did ask my question on MYSQL forums. But no one answered. I asked my question 3 days ago but still waiting for my answer. Hence, I asked here. Please help me. I am new in the world of database.
Re: Names along with sum(sal) [message #646616 is a reply to message #646615] Tue, 05 January 2016 10:17 Go to previous messageGo to next message
Danny Freeman
Messages: 11
Registered: December 2015
Location: UK
Junior Member
They have deleted my question. I don't know why. Sir, please help me in this.
Re: Names along with sum(sal) [message #646617 is a reply to message #646616] Tue, 05 January 2016 10:27 Go to previous messageGo to next message
gazzag
Messages: 906
Registered: November 2010
Location: Bristol, UK
Senior Member
As it is a SQL question, I don't see any harm in you asking the question. The way to get an answer is to provide a Test Case.
Re: Names along with sum(sal) [message #646618 is a reply to message #646617] Tue, 05 January 2016 12:07 Go to previous message
Michel Cadot
Messages: 65252
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

I agree but this Oracle SQL forum and MySQL does not support the same functions than Oracle (is there a SUM analytic function?).
We have a MySQL specific forum where I move this topic.

Previous Topic: New REPORT
Next Topic: getting output as per the column content
Goto Forum:
  


Current Time: Wed Dec 13 23:07:47 CST 2017

Total time taken to generate the page: 0.02552 seconds