Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: GROUP BY on...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3543 of 3717
Post > Topic >>

Re: GROUP BY on a column which might exist in one of two tables

by mark@[EMAIL PROTECTED] (Mark Stosberg) Jun 25, 2008 at 10:17 AM

> select
>     coalesce(h.partner_id, v.partner_id) as partner_id,
>     coalesce(v.count, 0) as total_views,
>     coalesce(h.count, 0) as total_hits
> from
>     (select partner_id, count(*) from hits group by partner_id) as h
>     full outer join
>     (select partner_id, count(*) from views group by partner_id) as v
>     on h.partner_id = v.partner_id
> ;
> 

That looks right. Thanks!



-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 1 Posts in Topic:
Re: GROUP BY on a column which might exist in one of two tables
mark@[EMAIL PROTECTED] (  2008-06-25 10:17:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 21:06:50 CDT 2008.