Skip to content

Instantly share code, notes, and snippets.

@stingh711
Created June 26, 2014 03:38
Show Gist options
  • Save stingh711/f323911969860d1fcb20 to your computer and use it in GitHub Desktop.
Save stingh711/f323911969860d1fcb20 to your computer and use it in GitHub Desktop.
Sql to get home page
SELECT
a.*, c.categoryName as articleCategoryName
FROM
ctms_article a
LEFT JOIN ctms_article b ON a.articleCategoryId = b.articleCategoryId
AND a.lastModified < b.lastModified
LEFT JOIN ctms_article_category c ON a.articleCategoryId = c.articleCategoryId
WHERE
a.state = 1
GROUP BY
a.articleCategoryId,
a.lastModified
HAVING
count(b.articleId) < 3
ORDER BY
a.articleCategoryId,
a.lastModified DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment