Forum OpenACS Q&A: Response to Help with SQL error

Collapse
Posted by Jonathan Ellis on
you need to post in html mode using the PRE tag to do what you want:
select date_id, n_sessions_day, decode(user_id,null,0,1) member_p,
  ((select count(distinct user_id) from historical_visits a
    where a.date_id = v.date_id)
    + (select count(distinct browser_id) from historical_visits b
    where b.date_id = v.date_id and b.user_id is NULL)) n_users
from historical_visits v
group by date_id, n_sessions_day, decode(user_id,null,0,1);
since you are doing a subselect there is no need for a group by at all here.