HI Everybody,
I have created one table called Employee.this table cantains four columns
ID,NAME,DEPTARTMENT,SALARY.
Now i want out put in below mentioned format.
Emp.ID Emp.Name Dept. Salary Total Salary by Dept
1 X1 Software 5000
2 X2 Software 7000
12000
3 X3 Testing 8000
4 X4 Testing 4000
5 X5 Testing 3000
15000
6 X6 HR 2000
7 X7 HR 1000
3000
Can anyone please help to get output in this format?
Thanks in advance.
amit
3 1361
HI Everybody,
I have created one table called Employee.this table cantains four columns
ID,NAME,DEPTARTMENT,SALARY.
Now i want out put in below mentioned format.
Emp.ID Emp.Name Dept. Salary Total Salary by Dept
1 X1 Software 5000
2 X2 Software 7000
12000
3 X3 Testing 8000
4 X4 Testing 4000
5 X5 Testing 3000
15000
6 X6 HR 2000
7 X7 HR 1000
3000
Can anyone please help to get output in this format?
Thanks in advance.
amit
-
-
SQL> ed
-
Wrote file afiedt.buf
-
-
1 select t.id,SUM(salary) from
-
2 (select 1 AS ID, 'X1' AS NAME, 'SW' AS DEPT, 1000 AS SALARY from dual
-
3 UNION
-
4 select 2 AS ID, 'X2' AS NAME, 'SW' AS DEPT, 1000 AS SALARY from dual
-
5 UNION
-
6 select 3 AS ID, 'X3' AS NAME, 'S' AS DEPT, 1000 AS SALARY from dual
-
7 UNION
-
8 select 4 AS ID, 'X4' AS NAME, 'S' AS DEPT, 3000 AS SALARY from dual) t
-
9* GROUP BY ROLLUP(dept,t.id)
-
SQL> /
-
-
ID SUM(SALARY)
-
---------- -----------
-
3 1000
-
4 3000
-
4000
-
1 1000
-
2 1000
-
2000
-
6000
-
-
7 rows selected.
-
-
SQL>
-
-
-
-
SQL> ed
-
Wrote file afiedt.buf
-
-
1 select t.id,SUM(salary) from
-
2 (select 1 AS ID, 'X1' AS NAME, 'SW' AS DEPT, 1000 AS SALARY from dual
-
3 UNION
-
4 select 2 AS ID, 'X2' AS NAME, 'SW' AS DEPT, 1000 AS SALARY from dual
-
5 UNION
-
6 select 3 AS ID, 'X3' AS NAME, 'S' AS DEPT, 1000 AS SALARY from dual
-
7 UNION
-
8 select 4 AS ID, 'X4' AS NAME, 'S' AS DEPT, 3000 AS SALARY from dual) t
-
9* GROUP BY ROLLUP(dept,t.id)
-
SQL> /
-
-
ID SUM(SALARY)
-
---------- -----------
-
3 1000
-
4 3000
-
4000
-
1 1000
-
2 1000
-
2000
-
6000
-
-
7 rows selected.
-
-
SQL>
-
-
Thanks for your reply,
but, i already got output in this format.
What i want is,"tolal salary by department" should be displayed in separate column. That i have mentioned below.
ID SUM(SALARY) Total Salary by Dept.
---------- ----------- ----------------------------
3 1000
4 3000
------------------------------------4000
1 1000
2 1000
------------------------------------2000
------------------------------------6000
Thanks in advance,
Amit Parmar
Try this: -
SQL> ed
-
Wrote file afiedt.buf
-
-
1 select empid,dept,salary ss,NULL from data1
-
2 UNION ALL
-
3 SELECT NULL,dept,NULL, sum(salary) from data1 group by dept
-
4 UNION ALL
-
5 SELECT NULL,NULL,NULL,SUM(SALARY) FROM data1
-
6* order by dept
-
SQL> /
-
-
EMPID DEPT SS NULL
-
---------- -------------------- ---------- ----------
-
1 SW 10000
-
2 SW 1000
-
5 SW 100
-
SW 11100
-
3 WWS 10000
-
4 WWS 1000
-
WWS 11000
-
22100
-
-
8 rows selected.
-
-
SQL>
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Craig Thomson |
last post by:
Do people generally try and output nicely formatted html from their
scripts?
I have been trying to, with variable indenting for tables etc. It
makes it easier to see the html and perhaps debug...
|
by: Mark |
last post by:
How do I output formatted numerical data to an external (text) file. At
a minimum I want to specify the number of decimal places to print.
Ideally I'd like the type of control the fortran FORMAT...
|
by: Matthew Thorley |
last post by:
Greetings, perhaps someone can explain this. I get to different styles
of formatting for xmla and xmlb when I do the following:
from elementtree import ElementTree as et
xmla =...
|
by: Joe C |
last post by:
I've written a console application and would like to isolate all screen
output so that it will be easier to migrate the code to a GUI-type platform
without modification to the base code. As a...
|
by: Jason Heyes |
last post by:
I am starting to worry about the performance of formatted read/write
operations on data-redundant objects in my program.What can I do to improve
this performance should it become an issue?
...
| |
by: Craig Petrie |
last post by:
Hi,
I have a large table in Word 2003 that has formatted text in the cells and
wish to read and convert a cells formatted contents to html output via
vb.net code. The formatting contains the...
|
by: rufi |
last post by:
hi group,
I am new to C and using gcc compiler in Linux.
I am having the following problems when using the printf() funtion to have the formatted output.
Here r some things which i m trying...
|
by: Jojo |
last post by:
Hi all,
I was wondering how I can perform formatted output with C++ strings. For
example, suppose I have in plain C:
sprintf(C_string, "%5.2f %6d");
How can I do such a thing with C++...
|
by: keith |
last post by:
I've been beating my head against this for a little while, so perhaps
someone can help me out here? The code below should output exactly as
follows (the hex data lines up in a fixed font):
DATA...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |