Re: How to restrict this query... (need subquery?)

2006-01-30 Thread René Fournier
Hi Peter, Yes, after I posted the question, I did some more reading and learned that it's possible to have several conditions in the ON clause. I tried: SELECT accounts.id, accounts.account_name, accounts.company_name, history.msg_src, COUNT(history.msg_src) as msg_num FROM accounts LEFT JOIN

Re: How to restrict this query... (need subquery?)

2006-01-30 Thread Rhino
o: Sent: Monday, January 30, 2006 5:01 PM Subject: How to restrict this query... (need subquery?) Hello, I have two tables: Accounts and History. Basically, I want to see how much activity each account has during a given period of time. Even if an account has no activity, I still want to see

Re: How to restrict this query... (need subquery?)

2006-01-30 Thread Peter Brawley
René >What I need to do, somehow, is apply that WHERE clause >to the COUNT part of the SELECT. Any ideas? Did you try moving your WHERE condition to the ON clause? PB - René Fournier wrote: Hello, I have two tables: Accounts and History. Basically, I want to see how much activity each

How to restrict this query... (need subquery?)

2006-01-30 Thread René Fournier
Hello, I have two tables: Accounts and History. Basically, I want to see how much activity each account has during a given period of time. Even if an account has no activity, I still want to see it in the result (naturally with zeros or null). In the history table, there is a column calle