sql group by dob in decades -


hi question lets say

we have student students table

student name dob ali          03/05/1991 apo          30/05/1993 haz          04/02/1983 nur          03/05/1986 

how can group them dob in decades result should be

1980-1989 haz nur 1990-1999 ali apo 

thanks

assuming dob column date or datetime, re-use first 3 digits in year part of dob, adding 0 or 9 create decade "grouping":

select     [student name],     left(convert(varchar(4), year([dob])), 3) + '0-' +     left(convert(varchar(4), year([dob])), 3) + '9' decade     students 

you can't group here, since every student unique. ui should responsible presenting students [decade].


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -