SQL query the day of the Recharge record import
SQL code
--Query the day's data select * from a where generatetime=sysdate--query for one weeks of data select * from a where (sysdate-generaetime) =7--query for one months data select * from a where months _between (sysdate,generatetime) =1 --query data for a given day select * from table where col between ' 2009-7-17 ' and ' 2009-7-18 ' select * from tb where datetime > ' 2010-5-14 ' and datetime< ' 2010-5-15 '--select * from tb where in a week datediff (Dd,date_time,getdate ()) <= 7SELECT * FROM TB WHERE DateDiff (Dd,date_time,getdate ()) between 0 and 7--24 hours forward from now Select * from tb where dateiff (Hh,date_time,getdate ()) <=24select * from tb where datediff (Hh,date_time,getdate ()) between 0 and 23----If it is datetime select name, sum (price) as Total Amount from Sales table where convert (varchar (6), closing time, 201311) = ' The name of ' group by ' --If the date is character select name, sum (price) as Total amount from sales form where left (Deal time, 7) = ' 2013-11 ' group by name
Python Statistics script
cat log.txt# time IP Recharge limit 2015-8-2 13:23:23 192.168.1.1 332015-8-2 13:23:23 192.168.1.1 362015-8-2 13:23:24 192.168.1.1 432015-8-2 13:23:25 192.168.1.3 232015-8-2 13:23:25 192.168.1.1 432015-8-2 13:23:34 192.168.1.3 932015-8-2 13:23:50 192.168.1.1 332015-8-2 13:23:50 192.168.1.1 232015-8-2 13:23:59 192.168.1.4 432015-8-2 13:23:59 192.168.1.4 532015-8-2 13:24:30 192.168.10.1 252015-8-2 13:24:30 192.168.10.1 252015-8-2 13:24:30 192.168.10.1 252015-8-2 13:24:30 192.168.10.1 25============================================logfile= ' Log.txt ' Ipa={}f=open ( logfile, ' R '). ReadLines () for i in f: ip=i.split () if ipa.get (ip[2]) == none: ipa.setdefault ( IP[2],&NBSP;IP[3]) else: ipa[ip[0]]+=ip[ 3] print (' total value per IP ') sorted (Ipa.items ()) For i in ipa: print ( I, ' the total amount of the same day is: ', Ipa.get (i))
SQL and Python statistics IP (user) top-up amount for the day