Created
June 26, 2014 03:38
-
-
Save stingh711/f323911969860d1fcb20 to your computer and use it in GitHub Desktop.
Sql to get home page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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