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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -