Adding custom SQL counter