Grouping data in a certain way in mysql -
i have query fetches data table called supervisor_approvals, want group rows of department , leave other department ungrouped each labref
supervisor approval structure looks ------------------------------------------------- labref department ab 1 ab 1 ab 0 ab 0 ab 0 xy 1 xy 0 xy 0
after query (result should be)
labref department ab 0 ab 1 ab 1 xy 0 xy 1
instead not show other labref data first 1 shown a http://sqlfiddle.com/#!2/6fb86/9!
my sql
select distinct * supervisor_approvals department = 0 , assign_status='0' group department union select * supervisor_approvals department = 1 , assign_status='0' order department desc
try:
select * supervisor_approvals group labref,department
Comments
Post a Comment