79181773

Date: 2024-11-12 15:36:51
Score: 0.5
Natty:
Report link

If your database is supporting analytical functions, you can consolidate into unique pairs before calculating count.

SELECT 
    LEAST("from", "to") AS user1,
    GREATEST("from", "to") AS user2,
    COUNT(*) AS count
FROM 
    messages
GROUP BY 
    LEAST("from", "to"), 
    GREATEST("from", "to");
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Jan Suchanek