sql - Sqlite Get counts of all distinct values across a row -


for personal end of year project i've scraped attendance off school website hoping form of visualization of data. i've gotten stuck transforming data form need in.

currently database looks this

date,one,two,three,four,five,six,seven,eight,nine,dee 2014-09-03,p,p,p,p,au,au,p,t*,au,p 2014-09-04,p,p,p,p,n/a,au,p,t*,n/a,p 2014-09-05,p,p,p,p,au,au,p,p,p,p 2014-09-09,p,p,p,p,au,au,p,p,au,p 2014-09-11,au,au,p,au,au,p,au,au,au,p 2014-09-15,p,p,p,p,au,p,p,p,au,p 2014-09-17,p,p,p,p,au,au,p,p,au,p 

the columns each period,and each 1 has indicator of presence. question is, possible turn using sqlite?

date,p,au,t*,n/a 2014-09-03,6,3,1,0 2014-09-04,6,1,1,2 2014-09-05,8,2,0,0 2014-09-09,7,3,0,0 2014-09-11,3,7,0,0 2014-09-15,8,2,0,0 2014-09-17,7,3,0,0 2014-09-19,9,1,0,0 

counting each occurence of value across row.

something this:

select date,        case when 1 = 'p' 1 else 0 end +        case when 2 = 'p' 1 else 0 end +        ...        case when dee = 'p' 1 else 0 end p,          case when 1 = 'au' 1 else 0 end +        case when 2 = 'au' 1 else 0 end +        ...        case when dee = 'au' 1 else 0 end au,         ... table 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -