|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
counting records
Hi,
first: sorry because of my bad language, but I´m not a native speaker... I´m a beginner in sql an asp. I need to create a report and would like to do it with asp. I have two tables. In table1 I need to count all records with the same id. The id of the first table refers to table 2 , and in table2 the category is assigned to the id. Now I want to create an output, which tells me the category with the summary of the id´s. Here is an example of the tables and the output: example of table1: ID Description .... 1 help 2 outlook doesn´t work 1 word is slow 1 excel-problem 2 need help 3 mail-problem ... example of table2: ID category 1 windows xp 2 windows 2000 3 windows nt ... the desired output: windows xp: 3 windows 2000: 2 windows nt: 1 It would be great, if you would help me... I need the sql statement. Thanks!! Traxx (from Germany) |
|
#2
|
|||
|
|||
|
I can't figure your example, where did the 3 for XP come from?
In general SELECT COUNT(*) as MyCount FROM table WHERE id=whatever will return a count value.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
||||
|
||||
|
try
Code:
SELECT A.Category, COUNT(*) As Total FROM Table2 As A INNER JOIN Table1 As B ON (A.ID = B.ID) GROUP BY A.Category ORDER BY Total DESC |
|
#4
|
|||
|
|||
|
Thanks a lot for your help!
This is what I am searching for... |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > counting records |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|