Re: Do I really need a subquery?

2006-08-13 Thread Peter Brawley
Geoffrey, >Do I really need that subquery? You need its scalar result just once, so why not ... SELECT url, @maxcount:=COUNT(1) FROM bi_bookmarks WHERE date > NOW() - INTERVAL 86400 SECOND GROUP BY url ORDER BY count DESC LIMIT 0, 1; SELECT title, url, COUNT(1) AS count, CEIL(COUNT(1) / (

Do I really need a subquery?

2006-08-12 Thread Geoffrey Sneddon
Hi, I've ended up with the following SQL: SELECT `title`, `url`, COUNT(1) AS `count`, CEIL(COUNT(1) / (SELECT COUNT(1) AS `count` FROM `bi_bookmarks` WHERE `date` > NOW() - INTERVAL 86400 SECOND GROUP BY `url` ORDER BY `count` DESC LIMIT 0, 1) * 8) AS `weight` FROM `bi_bookmarks` WHERE `d