empID Hobbies Salary
1 Cricket 100
1 Walleyball 100
1 Golf 100
2 Cricket 200
2 Golf 200
I need to get the data from the multiple tables and I want to display that in the report form 开发者_Go百科without repeating the primary key values.. in the above table it should not display empID for every hobby and I need to have the total of salary at the end of the report.
How to overcome such problem
If I understand what you are asking, this is not something you do in SQl, it is something you do in grouping in the report builder.
You are looking for something like this?:
empID Hobbies Salary
1 Cricket
Walleyball
Golf 300
2 Cricket
Golf 400
In five rows like that, or two rows like this:
empID Hobbies Salary
1 Cricket, Walleyball, Golf 300
2 Cricket, Golf 400
And which database system?
SELECT `empID`, SUM(`Salary`) AS `total_salary` FROM yourtable GROUP BY `empID`;
http://www.sql-tutorial.com/sql-group-by-sql-tutorial/
http://www.sql-tutorial.com/sql-aggregate-functions-sql-tutorial/
精彩评论