The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
help with query to select counts
I want to select the number of records for each idnumber that exists. In the below example, there are three 2's, four 3's, and three 4's. I want to capture this information in a single query if possible.
I know how to capture a record count for a single idnumber, but I'm not sure how to do capture counts for multiple idnumbers in one query. An example of the table: Code:
____________________ | idnumber | title | |------------------- | 2 | ..... | | 2 | ..... | | 2 | ..... | | 3 | ..... | | 3 | ..... | | 3 | ..... | | 3 | ..... | | 4 | ..... | | 4 | ..... | | 4 | ..... | |
#2
|
||||
|
||||
you need grouping:
[SQL]SELECT COUNT(*), idnumber FROM table GROUP BY idnumber[/sql] |
#3
|
||||
|
||||
i think he wants to capture the count of 2, then the count of 3's then the count of 4's
if that's the case, i'm not sure how to do it i'm afraid, it's what i'm reading up on now, but i'm pretty certain it's via a "while" |
#4
|
||||
|
||||
Quote:
|
#5
|
||||
|
||||
Quote:
|
#6
|
||||
|
||||
You're welcome Jake
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|