Ask a Question related to Dreamweaver AppDev, Design and Development.
-
hoohim #1
SQL Server counting records
Hi
I'm building a very basic forum with asp.net, The forum db is SQL2000 with 4
tables
users, forum, topics, replys
I have everything working fine with the exception of counts
On the forum page I have a repeater listing each entry in the forums table
I would like to show a count of the number of topics for each forum
Example:
Test Forum (45 Topics last post by Jo Bloggs)
Test Forum 2 (9 Topics last post by Joanne Bloggs)
Is it easier to add a field to the forums table called topicCount and update
that number everytime a new post is made or is there an easy way to build
the count into my stored procedure
Thanks in advance for any help received
hoohim Guest
-
counting down in a for
Hi all there is probably a much better way of doing all this i am working on the checkResults sub. it should find the pollerAudit log created... -
Counting (easy!)
I'm sure this is easy but I'm a newbie. I was doing control statements (for, while,etc.) like this: for ($count = 1; $count <= 5; $count++) {... -
Counting (easy!) (YES!!)
I think I figured it out! A FIRST!! for ($i = 1; $i <= 5; $i++){ sleep 1; print "$i\n"; } I prints out like this: 1...2...3...4...5 -
COUNTING PROBLEM !!!
I have a serious problem: Each time I run the following query the count result is changing! SELECT count(*) from posnad WHERE lfn_pos IS NULL ... -
Counting 1st Record only
Hello, I am trying to write a query which will identify only those members who have used either one or more services in a given year. 1 MemberID... -
RichMcCrea #2
Re: SQL Server counting records
You should be able to write one sql statement to reveal the count for the
children (topics) of the parent table (forum), relating the tables and creating
a group by clause.. As it is used here, the group by clause aggregates the
values in the the parent's child table. For example, SELECT FORUM. NAME,
FORUM, DESCRIPT, FORUM.CREATION_DT, COUNT(*) AS TOPIC_CNT FROM FORUM LEFT OUTER
JOIN TOPICS ON FORUM.ID=TOPICS.FORUM_ID GROUP BY FORUM. NAME, FORUM, DESCRIPT,
FORUM.CREATION_DT A RESULTING RECORDSET SAMPLE FOR THIS QUERY COULD BE AS
FOLLOWS NAME DESCRIPT CREATION_DT TOPIC_CNT science
science stuff 1/1/2001 5 politics worse
stuff 2/2/2002 3 the topic cnt field represents how
many topic there are in each forum
RichMcCrea Guest
-
hoohim #3
Re: SQL Server counting records
Excellent, many thanks
"RichMcCrea" <webforumsuser@macromedia.com> wrote in message
news:cvouhm$ogc$1@forums.macromedia.com...> You should be able to write one sql statement to reveal the count for the
> children (topics) of the parent table (forum), relating the tables and
> creating
> a group by clause.. As it is used here, the group by clause aggregates the
> values in the the parent's child table. For example, SELECT FORUM. NAME,
> FORUM, DESCRIPT, FORUM.CREATION_DT, COUNT(*) AS TOPIC_CNT FROM FORUM LEFT
> OUTER
> JOIN TOPICS ON FORUM.ID=TOPICS.FORUM_ID GROUP BY FORUM. NAME, FORUM,
> DESCRIPT,
> FORUM.CREATION_DT A RESULTING RECORDSET SAMPLE FOR THIS QUERY COULD BE AS
> FOLLOWS NAME DESCRIPT CREATION_DT TOPIC_CNT science
> science stuff 1/1/2001 5 politics
> worse
> stuff 2/2/2002 3 the topic cnt field
> represents how
> many topic there are in each forum
>
hoohim Guest



Reply With Quote

