Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Group By Question

Author  Topic 

BaldEagle
Starting Member

23 Posts

Posted - 2002-05-04 : 07:43:30
SELECT COUNT(*) AS iCount, *
FROM PEP_DiaryEntry

There is an error whe i run the above statement. A group by clasuse from wat i see.

This is the table structure.

DiaryEntryID (PK)int
DiaryID (FK)int
MoodID (FK)int
EntryDate date
Entry nvarchar

chadmat
The Chadinator

1974 Posts

Posted - 2002-05-05 : 04:42:04
What is it you are trying to get?

This query will return an error because you need to have each of your select columns in a group by when used with an aggregate function (Like Count). So in your case all of the colums you listed would need to be in a group by clause.

-Chad



Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-05-06 : 00:11:14
I second the question of "What is it you are trying to get?". It appears that your statement is attempting to return the total count of all rows in your table, AND the data from all rows. Is that what you want? Then perhaps you should look into SELECT @@ROWCOUNT after your SELECT * statement.

OR, are you trying to return a recordset where each row has an incrementing integer to number them? In that case, you might do an INSERT into a temp table that has an IDENTITY field. But I doubt that you'll really want to do that for the entire table (i.e. you have no where clause or ORDER BY).

So, again, what's the goal? Maybe there's a better way.

Go to Top of Page
   

- Advertisement -