Guest User

Untitled

a guest
May 25th, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. SELECT zone, DATE_FORMAT(creation_date, '%Y%u') AS date, COUNT(DISTINCT vessel_imo) AS vessel_count FROM vessel_position
  2. WHERE zone IS NOT NULL
  3. AND creation_date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
  4. GROUP BY zone, date;
  5.  
  6. +----+-------------+-----------------+------------+-------+--------------------+------+---------+------+----------+----------+------------------------------------------+
  7. | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
  8. +----+-------------+-----------------+------------+-------+--------------------+------+---------+------+----------+----------+------------------------------------------+
  9. | 1 | SIMPLE | vessel_position | NULL | range | creation_date,zone | zone | 5 | NULL | 21190904 | 50.00 | Using where; Using index; Using filesort |
  10. +----+-------------+-----------------+------------+-------+--------------------+------+---------+------+----------+----------+------------------------------------------+
Add Comment
Please, Sign In to add comment