[thelist] sql query - how to evenly distributed results
r937
rudy at r937.com
Wed Feb 28 15:49:23 CST 2007
<voice type="homer">doh!</voice>
select a.gallery_id
, a.gallery_title
, b1.image_id
, b1.image_adddate
from galleries as a
inner
join images as b1
on a.gallery_id = b1.image_gallery_id
inner
join images as b2
on a.gallery_id = b2.image_gallery_id
and b1.image_adddate <= b2.image_adddate
where a.gallery_id in ( 1, 2 )
group
by a.gallery_id
, a.gallery_title
, b1.image_id
, b1.image_adddate
having count(*) <= 4
order
by a.gallery_id
, b1.image_adddate desc
More information about the thelist
mailing list