-
Notifications
You must be signed in to change notification settings - Fork 0
SQL
mitochondrion edited this page Dec 12, 2016
·
12 revisions
##Examples Most X of the Day
SELECT X, count(X) FROM some_table WHERE some_condition AND date_column between '2016-04-01 00:00:00' and '2016-04-01 23:59:00' GROUP BY X ORDER BY COUNT(X) DESCTop X of the day (Historical)
SELECT date, X, MAX(count)
FROM (SELECT DATE(date_column) as date, X, COUNT(X) as count
FROM some_table
WHERE some_condition
GROUP BY DATE(date_column), symbol
ORDER BY DATE(date_column) DESC, COUNT(X) DESC) as whatever
GROUP BY date
ORDER BY date DESC, count DESCFind containing
SELECT * FROM some_table WHERE some_column LIKE "%string to look for%"Rows per date
SELECT DISTINCT(DATE(date_column)), count(date_column) FROM some_table GROUP BY DATE(date_column)