Forums

This topic is locked

A simple SQL count

Posted 16 May 2002 17:30:13
1
has voted
16 May 2002 17:30:13 Garo Maka posted:
How do you make a simple count from an acces QueryTable? Im using ASP

I want to count the number of news writen by a specific author, but cant get it to work.

Im trying:
SELECT *
(COUNT (*) WHERE NEWS_ID = NEWS.NEWS_AUTHOR_ID) AS NO_AUTHORNEWS FROM QryNewsCombined

Whats wrong?



Edited by - Fredski_dk on 16 May 2002 18:07:25

Replies

Replied 16 May 2002 18:12:30
16 May 2002 18:12:30 Matthijs Horsman replied:
Hi Fredsi,

I came up with this:

SELECT (SELECT COUNT(*)
FROM links
WHERE links.CAT_ID = cat.id) AS TOTAL_LINKS, * FROM cat;

I have two tables:
1. Links (ID = CAT_ID)
2. cat (ID= id)

It counts the recors from the LINKS table where the ID from the links table matches the ID from the cat table

after reading this tutorial right here on UDzone... <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle><img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

www.udzone.com/showDetail.asp?TypeId=2&NewsId=923

remember you have to make a relationship between the tables

hope this helps

Matthijs
----------------
UD4/WY2K/IIS/ASP-VB
www.chaps.nl
Replied 17 May 2002 02:52:38
17 May 2002 02:52:38 Garo Maka replied:
Thanks for your reply.
It does not seem to work for this situation.

I have the query that unites to diferent tables, NEWS and NEWS_AUTHORS. The results show news and author info. But I like to add news count for the specifik author. To count the number of news that each author has writen by using their author_ID.

Is there a way of doing this in one table and using a query?

Thanks

Reply to this topic