SELECT *
FROM table
WHERE id>(SELECT max(id)
FROM table
WHERE date < CURDATE())
LIMIT 10
select datatime,
sum(case when card = 1 then amount else 0 end) as 'Cards1',
sum(case when card = 2 then amount else 0 end) as 'Cards2',
sum(case when card = 3 then amount else 0 end) as 'Cards3'
from service
group by datatime
import logging
# create logger with 'spam_application'
logger = logging.getLogger('MyApp')
logger.setLevel(logging.DEBUG)
# create file handler which logs even debug messages
fd = logging.FileHandler('MyApp_Debug.log')
fd.setLevel(logging.DEBUG)
# create file handler which logs even error messages
fe = logging.FileHandler('MyApp_Error.log')
fe.setLevel(logging.ERROR)
# add the handlers to the logger
logger.addHandler(fd)
logger.addHandler(fe)
logger.debug('test message debug')
logger.error('test message error')