-
Notifications
You must be signed in to change notification settings - Fork 2
Useful SQL queries
sfelixwu edited this page Feb 22, 2016
·
7 revisions
select YEAR(created_time) as year, count(*) from sincere.post group by year;
+------+----------+
| year | count(*) |
+------+----------+
| 0 | 1494 |
| 1970 | 55 |
| 1971 | 49 |
| 1972 | 50 |
| 1973 | 39 |
| 1974 | 42 |
| 1975 | 38 |
| 1976 | 35 |
| 1977 | 41 |
| 1978 | 55 |
| 1979 | 69 |
| 1980 | 68 |
| 1981 | 59 |
| 1982 | 71 |
| 1983 | 72 |
| 1984 | 81 |
| 1985 | 74 |
| 1986 | 78 |
| 1987 | 74 |
| 1988 | 85 |
| 1989 | 72 |
| 1990 | 76 |
| 1991 | 84 |
| 1992 | 76 |
| 1993 | 81 |
| 1994 | 92 |
| 1995 | 106 |
| 1996 | 106 |
| 1997 | 93 |
| 1998 | 97 |
| 1999 | 138 |
| 2000 | 139 |
| 2001 | 147 |
| 2002 | 150 |
| 2003 | 156 |
| 2004 | 194 |
| 2005 | 259 |
| 2006 | 4165 |
| 2007 | 19817 |
| 2008 | 276168 |
| 2009 | 1946573 |
| 2010 | 8023282 |
| 2011 | 21819128 |
| 2012 | 25981242 |
| 2013 | 8169170 |
| 2014 | 297309 |
| 2015 | 1543 |
+------+----------+select fb_id, count(*) as count from sincere.comment \
group by fb_id order by count desc limit 8192 \
into outfile '/tmp/sfw_comment.txtselect YEAR(created_time) as year, count(*) from sincere.comment where page_id = '25987609066' group by year;
select fb_id, fb_name, count(*) as count from comments group by fb_id order by count desc limit 30;
+-----------------+----------------------------------+--------+
| fb_id | fb_name | count |
+-----------------+----------------------------------+--------+
| 159616034235 | Walmart | 239099 |
| 136343883058494 | David Venable QVC | 124000 |
| 8576093908 | AT&T | 122305 |
| 18801397386 | AirAsia | 80412 |
| 187956507940013 | Holdin' Holden | 66008 |
| 191027189287 | EA SPORTS FIFA | 62412 |
| 7292863341 | Boost Mobile | 57489 |
| 273795515772 | KLM | 52430 |
| 7224956785 | Samsung Mobile USA | 52247 |
| 116933095047216 | Download Igrica,Filmova,Programa | 49140 |
| 108726828894 | T-Mobile | 47670 |
| 169297109748354 | choxi | 47006 |
| 35313373389 | Sony Mobile | 44860 |
| 45347040850 | DISH | 44044 |
| 163675207028951 | Coupon cousins | 41970 |
| 6067784583 | Carnival Cruise Line | 41499 |
| 101063233083 | HTC | 39166 |
| 1765465371 | Ernest Delesma Sr | 38393 |
| 105923789463852 | Engineer Vs Doctor | 38174 |
| 1028814892 | Chris Poulsen | 37803 |
| 159072176449 | Alitalia | 37147 |
| 136336876521150 | Sun Gazing | 36073 |
| 116991551664925 | Army Jobs | 35521 |
| 142405469104684 | AT&T U-verse | 34739 |
| 230486520354731 | BMW Iraq | 34537 |
| 8389383510 | Sprint | 34104 |
| 23797290954 | QVC | 34040 |
| 239043421105 | Pixels2Pages | 32828 |
| 154423787905266 | NULL | 29767 |
| 1600191335 | Roger Aldi | 28923 |
+-----------------+----------------------------------+--------+
30 rows in set (9 hours 51 min 53.53 sec)select YEAR(date) as year, count(*) from crawling.post group by year;