Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
25.03.2012 IST ANK 12:35
26.03.2012 IST ANK 12:35
27.03.2012 IST ANK 12:35
28.03.2012 IST ANK 12:35
29.03.2012 IST ANK 16:00
30.03.2012 IST ANK 16:00
31.03.2012 IST ANK 16:00
01.04.2012 IST ANK 12:35
02.04.2012 IST ANK 12:35
03.04.2012 IST ANK 12:35
04.04.2012 IST ANK 12:35

Grouping in this way need thereof
25.03.2012 - 28.03.2012 IST ANK 12:35
29.03.2012 - 31.03.2012 IST ANK 16:00
01.04.2012 - 04.04.2012 IST ANK 12:35
Posted

If your table is

Field1         Field2   Field3   Field4
25.03.2012 IST       ANK     12:35
26.03.2012 IST       ANK     12:35
27.03.2012 IST       ANK     12:35
28.03.2012 IST       ANK    12:35
.
.
.
.

Write the sql for your output-
SQL
Select convert(varchar(20),MIN(Field1)) +' - '+ convert(varchar(20),MAX(Field1)) ,Field2, Field3, Field4 from YourTableName Group by Field2, Field3, Field4
 
Share this answer
 
Try this:

SQL
select colTime, col2, convert(varchar(20), min(colDate)) + ' - ' + convert(varchar(20), max(colDate))from table1
group by colTime, col2
 
Share this answer
 
Comments
matrixboy22 27-Feb-12 9:40am    
When you specify the group will not result in this way.
25.03.2012 - 28.03.2012 IST ANK 12:35
29.03.2012 - 31.03.2012 IST ANK 16:00
01.04.2012 - 04.04.2012 IST ANK 12:35
.
[no name] 27-Feb-12 13:28pm    
Did you try the query?

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