SQL
- 1 ответ
- 0 вопросов
1
Вклад в тег
Курсоры зло.
begin tran
create table #res (
ID int not null identity(1, 1),
[Date] datetime not null,
Name varchar(100) not null,
constraint PKres primary key ( Id )
)
insert #res ([Date], Name) values ('20150611 10:00', 'Пупкин')
insert #res ([Date], Name) values ('20150611 12:00', 'Пупкин')
insert #res ([Date], Name) values ('20150611 10:30', 'Иванов')
select dateadd(day, datediff(day, 0, [Date]), 0) [Day], min([Date]) Start, Name
from #res
group by dateadd(day, datediff(day, 0, [Date]), 0), Name
order by min([Date])
rollback