SQL Server : GROUP error
NickName:Rashad Aliyev Ask DateTime:2015-02-16T20:54:19

SQL Server : GROUP error

I have a problem in SQL Server. I have a table name rTable and inside many columns of different types (Date, XML, varchar and so..)

Now I need group by one of this columns.

SELECT TOP 100 *
FROM rTable
GROUP BY integer_column

But this query give me error.

In MySQL it working normaly, but SQL Server asking me for do some operation in group with another columns, I need just show it.

What is recomendation?

Copyright Notice:Content Author:「Rashad Aliyev」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/28541871/sql-server-group-error

Answers
Jenish Rabadiya 2015-02-16T13:04:35

You can not select all the column with group by clause in MS SQL.\n\nSELECT integer_column, count(integer_column)\nFROM rTable\nGROUP BY integer_column\n\n\nand also can use aggregate function like count, sum in select clause if you wanted.",


Holger Jakobs 2015-02-16T13:08:13

Actually, this is not a limitation of MS SQL (although it has many), but it is conforming to the SQL standard.\n\nYou have to name all columns in the GROUP BY clause, except those using an aggregate function.",


More about “SQL Server : GROUP error” related questions

SQL Server : GROUP error

I have a problem in SQL Server. I have a table name rTable and inside many columns of different types (Date, XML, varchar and so..) Now I need group by one of this columns. SELECT TOP 100 * FROM ...

Show Detail

SQL Server GROUP BY error

Here is the query I am trying to run: SELECT TOP 5 PageComment.ID FROM PageComment WHERE PageComment.ParentID IN (SELECT ID FROM ProjectPage) GROUP BY PageComment.ParentID What I want to...

Show Detail

GROUP BY error in SQL Server

When I delete Group By clause it works. The main problem is that the query gets repeated rows, so I added Group By to clear the results. SELECT TOP 5 O.ItemCode, O.ItemName FROM OITM O J...

Show Detail

Microsoft SQL Server: Error with Group By

I'm new to Microsoft SQL Server 2014. I run this SQL code: SELECT TOP(10) 'DBSG' as seek_entity, * FROM DBSG..PM00200 and get this result: Next, I want to find out total line items for that entity

Show Detail

Group by is throwing error in SQL Server

I want to group by service name to all my record and I am using this query in SQL Server but it's throwing an error select max(c.service_id) as service_id, a.ser_id, b.UserID, SQRT(POWER(69....

Show Detail

Each GROUP BY expression error in sql server

I am building a stored procedure in MS SQL SERVER 2012. I want to display average level of current day. CREATE PROCEDURE [dbo].[AverageP] @UserID INT AS BEGIN SELECT DAY(GETDATE()), AVG(Le...

Show Detail

Group by * in SQL Server

I have a table, say, A with 100 columns. I am trying to join another table B to this, which has certain measures which need to be aggregated to the level of the first table, which means I need to g...

Show Detail

Group by working in SQL Server 2000 but not in SQL Server 2005

I used following query in SQL Server 2000 SELECT U.FirstName, SUM(VE.Score)AS Score, SUM(VE.QuizTime) AS Time, SUM(VE.IsQuizType) AS QuizesAttempted, SUM(VE.IsProgrammingType) AS

Show Detail

UNION and GROUP BY in SQL server

I need help for create a View in SQL Server. I have some thing like this SELECT MemberId, Name, SUM(TotalSales) as SalesAmount, CreatedOn FROM ( ...

Show Detail

Cannot connect to SQL Server as a member of AD group

I am facing an error to connect to SQL Server as a member of a new AD group. Could anyone advise below? I am a member of an AD group and this AD group has DB owner access in the instance and datab...

Show Detail