mysql - Conditional SQL report -
suppose have table contains:
serial# colorcount bwcount ============================== 12345 23 56 80023 0 459 22903 1 999
and want generate report looks like:
sn description value ============================== 12345 "bwcount" 56 12345 "colourcount" 23 80023 "bwcount" 459 22903 "bwcount" 999 22903 "colourcount" 1
so that...
- the bwcount , colourcount values output different rows, and
- if colourcount value device (sn) 0 not output
is possible raw sql? , if yes, please show me how or point me in right direction. i've done work mysql simple queries. have never seen done before.
you union
2 queries return data need, example:
select serial, 'bwcount' description, bwcount value serial union select serial, 'colourcount' description, colourcount value serial colourcount > 0
Comments
Post a Comment