Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. +-------------+--------------+------+-----+---------+----------------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +-------------+--------------+------+-----+---------+----------------+
  4. | id | bigint(20) | NO | PRI | NULL | auto_increment |
  5. | location_id | bigint(20) | YES | MUL | NULL | |
  6. | price | double | NO | | NULL | |
  7. | start_date | datetime | NO | | NULL | |
  8. +-------------+--------------+------+-----+---------+----------------+
  9.  
  10. select * from rate r INNER JOIN (SELECT r2.start_date,r2.id as
  11. id,r2.location_id, min(ABS(DATEDIFF(r2.start_date, NOW()))) AS version FROM rate r2
  12. GROUP BY r2.location_id) o2 ON ( o2.id=r.id and r.start_date=o2.start_date);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement