[thelist] sql query - how to evenly distributed results

r937 rudy at r937.com
Wed Feb 28 15:24:55 CST 2007


sorry, bob, try this please --

  select a.gallery_id
       , a.gallery_title
       , b1.image_id
       , b1.image_date_added
    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