sql - SQLite conditional output -


i need output x in column in report created using sqlite.

i need find patern, , if pattern exsists record output x, if not found output blank space.

heres have.

select `device_type` "device", substr(`model`, 1, 30) "model",   `location` "location",   (case when (`user_tag` "%decommissioned%" "x" else " " end) "decom",   count(`id`) "count" `devices` group `device_type` order `device` asc; 

its reporting

near "then": syntax error 

like said, can use sql putting report together. little limiting im allowed use this.

thanks in advance help.

i think right syntax:

select `device_type` device,        substr(`model`, 1, 30) model,        `location` "location",         (case when `user_tag` "%decommissioned%" "x" else " " end) "decom",         count(`id`) "count" `devices` group device_type, substr(`model`, 1, 30), location,          (case when `user_tag` "%decommissioned%" "x" else " " end) order `device` asc; 

you have opening paren. in addition, group by clause not match select in terms of columns being used define groups.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -