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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -