Click here to Skip to main content
15,920,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi All, I want to know is there any way, to remove duplicate values from resultset and merge that columns. Let me clarify by showing query and resultsets.
SQL
SELECT DENSE_RANK() OVER (ORDER BY EmpID) AS [SrNo], EmpID, EmpName,
Location, Department, CONVERT(varchar(10), AttDate, 103) AS AttDate, TimeIn, TimeOut, AttStatus
FROM tbl_Att


CSS
SrNo    EmpID   EmpName Location    Department  AttDate TimeIn  TimeOut AttStatus
1       T001    TestEmp1    Mumbai  Admin   12/9/2015   0:00:00 16:30:00    AB
1       T001    TestEmp1    Mumbai  Admin   13/09/2015  8:00:00 00:00:00    AB
2       T002    TestEmp2    Mumbai  Admin   12/9/2015   9:00:00 18:30:00    PR
2       T002    TestEmp2    Mumbai  Admin   13/09/2015  9:30:00 18:30:00    PR
2       T002    TestEmp2    Mumbai  Admin   14/09/2015  9:30:00 18:30:00    PR
2       T002    TestEmp2    Mumbai  Admin   15/09/2015  9:30:00 18:30:00    PR
3       T003    TestEmp3    Mumbai  Admin   15/09/2015  9:00:00 20:30:00    PR


I want to display output like this :-

CSS
SrNo    EmpID   EmpName Location    Department  AttDate TimeIn  TimeOut AttStatus
1       T001    TestEmp1    Mumbai  Admin   12/9/2015   0:00:00 16:30:00    AB
                                            13/09/2015  8:00:00 0:00:00     AB
2       T002    TestEmp2    Mumbai  Admin   12/9/2015   9:00:00 18:30:00    PR
                                            13/09/2015  9:30:00 18:30:00    PR
                                            14/09/2015  9:30:00 18:30:00    PR
                                            15/09/2015  9:30:00 18:30:00    PR
3       T003    TestEmp3    Mumbai  Admin   15/09/2015  9:00:00 20:30:00    PR


Will it be possible through SQL Query???
Please help.
Posted

1 solution

No, it's not possible in the query itself. Your UI code that displays this data is responsible for that, not SQL server.
 
Share this answer
 
Comments
Umesh AP 8-Sep-15 6:04am    
It requires lots of efforts to do this in code behind file, that's why I need output in required format through SQL query. Any other suggestion???
Dave Kreskowiak 8-Sep-15 8:04am    
You don't have any other options. It's either done in your UI code or it's not done at all.
Umesh AP 8-Sep-15 8:12am    
Ok, Thanks for reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900