The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
SQL COUNT(condition)?
Hi,
I have two queries: Code:
SELECT COUNT(*) AS comments FROM ng_comment WHERE ng_comment.collectionid = 47 Code:
SELECT COUNT(*) AS comments2 FROM ng_comment WHERE ng_comment.collectionid = 47 AND ng_comment.dateline <= 1262487011 I was thinking something like: Code:
SELECT COUNT(*) AS comments, COUNT(IF ng_comment.dateline <= 1262487011) AS comments2 FROM ng_comment WHERE ng_comment.collectionid = 47 Any help? Thanks. PS. I also posted this on vbulletin.com, but I think this forum is a bit busier than the programming discussion on vbulletin.com. (http://www.vbulletin.com/forum/showt...28condition%29) --------------- Added [DATE]1263058583[/DATE] at [TIME]1263058583[/TIME] --------------- I figured it out for myself. I used: Code:
SELECT COUNT(*) AS totalcomments, COUNT(CASE WHEN ng_comment.dateline <= 1262487011 THEN 1 ELSE null END) AS newercomments FROM ng_comment WHERE ng_comment.collectionid = 47 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|