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

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

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

html - jQuery UI Sortable - Remove placeholder after item is dropped -