Generally you would do that with a count function instead of relyingon something else.
"select * from layer where visible = 1"
so I guess "SELECT COUNT(*) FROM layer WHERE visible=1" would give youthe answer.
- Adam