Re: [SQL] Get the max viewd product_id for user_id

2010-12-05 Thread Jayadevan M
> > The issue in both approaches is that if I have two product_ids that are > > viewed same number of times and share the first place as most viewed > > products by that user, I'll get only one of them (LIMIT 1 OR MAX() can > > only return one row :). > > > > And then, to jump again into my own m

Re: [SQL] Get the max viewd product_id for user_id

2010-12-05 Thread Mario Splivalo
On 12/05/2010 05:57 PM, Mario Splivalo wrote: The issue in both approaches is that if I have two product_ids that are viewed same number of times and share the first place as most viewed products by that user, I'll get only one of them (LIMIT 1 OR MAX() can only return one row :). And then, to

Re: [SQL] Get the max viewd product_id for user_id

2010-12-05 Thread Mario Splivalo
On 12/03/2010 12:40 PM, Jayadevan M wrote: Hello, I went this way, but for a large number of user_id's, it's quite slow: CREATE VIEW v_views AS SELECT user_id, product_id, count(*) as views FROM viewlog GROUP BY user_id, product_id SELECT DISTINCT user_id, (SELECT product_

Re: [SQL] Get the max viewd product_id for user_id

2010-12-05 Thread Mario Splivalo
On 12/03/2010 12:40 PM, Jayadevan M wrote: Hello, I went this way, but for a large number of user_id's, it's quite slow: CREATE VIEW v_views AS SELECT user_id, product_id, count(*) as views FROM viewlog GROUP BY user_id, product_id SELECT DISTINCT user_id, (SELECT product_