Merge columns [message #285281] |
Tue, 04 December 2007 03:34  |
Hunter_wow
Messages: 31 Registered: November 2007
|
Member |
|
|
Hello. I would like to know how to merge(or what to call it) columns in oracle. Example:
Table 1:
Employe | Project
Table 2:
Project | Sallary
Every employe will have made a number of projects. How can I get a table with the total sallary for every employe? I cant think of any way to solve it. Any tips?
[Updated on: Tue, 04 December 2007 03:34] Report message to a moderator
|
|
|
|
|
|
|
Re: Merge columns [message #285299 is a reply to message #285281] |
Tue, 04 December 2007 03:51   |
Hunter_wow
Messages: 31 Registered: November 2007
|
Member |
|
|
Yea, thanks a lot! Guess it´s my lucky day =P. I belive I manage to put together all employs and their points but still dont understand how I should Sum it together:
SELECT a.sallary, b.employe FROM table1 a, table2 b WHERE a.project = b.project;
Example view for the result:
Sallary | Employe
5000 rajavu1
10000 Michel
1000 rajavu1
Need to make some kind of Join and Sum in the same time for this?
[Updated on: Tue, 04 December 2007 03:54] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Merge columns [message #285375 is a reply to message #285281] |
Tue, 04 December 2007 05:45   |
|
Quote: | This gave me the result I wanted:
SELECT Employe, SUM(Sallary) as "Sallary"
FROM table
GROUP BY Employe;
|
Then this is not your actual desired output anyway!
I hardly can find joining table1 and table2 in the above query. It is there in your second post, but not here.
Kiran,
[Updated on: Tue, 04 December 2007 05:47] Report message to a moderator
|
|
|
Re: Merge columns [message #285444 is a reply to message #285368] |
Tue, 04 December 2007 11:05  |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
Quote: | Table 1: Employe | Project
Table 2: Project | Sallary
Every employe will have made a number of projects.
| So, if I understand the data model, there is N:1 relationship between Table1 and Table2.
Quote: | I managed to put together table1 and table2 to one table
| If my assumption is correct, you just broke the second normal form. Not a good idea at all.
Prepare for many difficulties, especially the possibility of having different Sallary values for one Project.
|
|
|