Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT zone, DATE_FORMAT(creation_date, '%Y%u') AS date, COUNT(DISTINCT vessel_imo) AS vessel_count FROM vessel_position
- WHERE zone IS NOT NULL
- AND creation_date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
- GROUP BY zone, date;
- +----+-------------+-----------------+------------+-------+--------------------+------+---------+------+----------+----------+------------------------------------------+
- | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
- +----+-------------+-----------------+------------+-------+--------------------+------+---------+------+----------+----------+------------------------------------------+
- | 1 | SIMPLE | vessel_position | NULL | range | creation_date,zone | zone | 5 | NULL | 21190904 | 50.00 | Using where; Using index; Using filesort |
- +----+-------------+-----------------+------------+-------+--------------------+------+---------+------+----------+----------+------------------------------------------+
Add Comment
Please, Sign In to add comment