Re: Adding annotations to raw sql

2014-12-10 Thread john
should that be "t.ct" Johnf On 12/10/2014 03:23 PM, Ruslan Batukaev wrote: Suppose I have the following SQL query: SELECT a.id, ct, 1 as one FROM article a LEFT JOIN ( SELECT article_id, count(distinct(tag)) AS ct FROM article_tag WHERE tag IN ('football', 'te

Adding annotations to raw sql

2014-12-10 Thread Ruslan Batukaev
Suppose I have the following SQL query: SELECT a.id, ct, 1 as one FROM article a LEFT JOIN ( SELECT article_id, count(distinct(tag)) AS ct FROM article_tag WHERE tag IN ('football', 'tennis', 'django', 'mma') GROUP BY article_id ORDER BY ct