sql - How to select with grouping on a subset of columns -
select datepart(yy, date1) year, datepart(mm, date1) month, datepart(dd, date1) day, datepart(hh, date1) hour , min(datepart(mi, date1)) minute, datediff(mi, date1, date2) aaa mytb with(nolock) group datepart(yy, date1), datepart(mm, date1), datepart(dd, date1), datepart(hh, date1), datepart(mi, date1) order datepart(yy, date1) , datepart(mm, date1), datepart(dd, date1), datepart(hh, date1), datepart(mi, date1)
this sql not working, don't want add datediff(mi, date1, date2)
group by
clause. solution?
found answer:
need use aggragate function min,sum
etc.
in code:
select .... max(datediff(mi, date1, date2))
Comments
Post a Comment