Tuesday, February 14, 2012

mysql min max in condition

mysql> select profile_id, min(date(created_on)), max(date(created_on)) from sig_dumps group by profile_id having min(date(created_on))!= max(date(created_on)) ;
+------------+-----------------------+-----------------------+
| profile_id | min(date(created_on)) | max(date(created_on)) |
+------------+-----------------------+-----------------------+
| 3 | 2012-02-07 | 2012-02-14 |
| 4 | 2012-02-07 | 2012-02-14 |
| 5 | 2012-02-07 | 2012-02-14 |
| 9 | 2012-02-07 | 2012-02-14 |
+------------+-----------------------+-----------------------+
4 rows in set (0.00 sec)

No comments:

Post a Comment