Longest query of my life
mysql -H -u mauj -p mauj -e “select count(*) as DownloadCount,W.phone as PhoneModel,sum(W.un) as NumberOfUser from (select count(*) as un,mo ,phone from wap_tran_1 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_2 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_3 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_4 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_5 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_6 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_7 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_12 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_13 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_14 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_32 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_33 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_57 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_172 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_171 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_173 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_203 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_204 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_205 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_206 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_207 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_208 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo) as W group by W.phone” > /home/pravin/vodaphone.html