\pset border 2
\pset format aligned

\echo '== Garry vs Gurpreet on westin =='
SELECT u.id, u.login, u.active, u.share, u.create_date, u.write_date,
       u.x_fc_tech_sync_id,
       (SELECT COUNT(*) FROM fusion_technician_task t WHERE t.technician_id = u.id) AS total_tasks,
       (SELECT MAX(create_date) FROM fusion_technician_task t WHERE t.technician_id = u.id) AS last_task_create,
       (SELECT COUNT(*) FROM mail_message m WHERE m.author_id = u.partner_id) AS messages
FROM res_users u
WHERE u.id IN (2, 85);

\echo ''
\echo '== HK detail on westin =='
SELECT u.id, u.login, p.name AS partner_name, p.email, p.phone, p.mobile,
       u.x_fc_is_field_staff, u.x_fc_tech_sync_id, u.active
FROM res_users u
JOIN res_partner p ON p.id = u.partner_id
WHERE u.id = 39;
