开发者

I need to get the data from the multiple tables and I want to display that in the report form without repeating the primary key values

开发者 https://www.devze.com 2023-02-19 02:20 出处:网络
empIDHobbiesSalary 1Cricket100 1Walleyball100 1Golf100 2Cricket200 2Golf200 I need to get the data from the multiple tables and I want to display that in the report form 开发者_Go百科without repeati
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/

0

精彩评论

暂无评论...
验证码 换一张
取 消