Count distinct column case when/conditional
Try this:
COUNT(DISTINCT CASE WHEN messages.link_label IS NOT NULL THEN messages.id ELSE NULL END)AS link_created
Try this:
COUNT(DISTINCT CASE WHEN messages.link_label IS NOT NULL THEN messages.id ELSE NULL END)AS link_created