SQL Server CE GROUP BY clause
NickName:user1375948 Ask DateTime:2012-08-24T19:37:24

SQL Server CE GROUP BY clause

I have to use GROUP BY statement to pull data from SQL Server CE.

Now I'm getting

In aggregate and grouping expressions, the SELECT clause can contain only aggregates and grouping expressions. [ Select clause = ,Date ]

but I really want to get date.

Query is as follows

SELECT Date 
FROM Installments 
GROUP BY ID 
HAVING Sr = max(Sr)

What am I doing wrong? Please explain

Copyright Notice:Content Author:「user1375948」,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/12108682/sql-server-ce-group-by-clause

Answers
Gonzalo.- 2012-08-24T11:41:57

When you use group by, you group by some field, and apply an aggregate function.\nSo, in the select, you shoud that field (the grouped result) and then the result of the function used.\n\nMaybe you want something like \n\nSELECT Id, Max(date) FROM Installments GROUP BY ID \n\n\nIt will depends on what you want.\n\nRead about Group by here",


Justin Harvey 2012-08-24T11:40:50

If you are grouping by ID, then each group could potentially have multiple different dates, so you can't select Date. You could, for example, \n\nselect Max(Date) FROM Installments GROUP BY ID \n",


More about “SQL Server CE GROUP BY clause” related questions

SQL Server CE GROUP BY clause

I have to use GROUP BY statement to pull data from SQL Server CE. Now I'm getting In aggregate and grouping expressions, the SELECT clause can contain only aggregates and grouping expressions...

Show Detail

SQL Group By question SQL Server 2005 CE

I'm having a problem with an sql query that i use for my mobile application which uses sql server 2005 ce. I'm not so good with t-sql, so have a problem with this query SELECT TP.ID_TASK_MASTER, TP.

Show Detail

SQL Server CE dealing with parameter in clause of type integer

I would like to select rows, update rows or delete rows by passing the values as a parameter to operate on an IN clause. It works when dealing with string type or (varchar) type but fails when deal...

Show Detail

SQL Server CE: Update statement using DateTime in Where clause

I need to be able to update time information for a row in the table. The id is not unique so I also use the startTime column to find the specific row. I am using SQL Server CE and C# so the date ob...

Show Detail

SQL Server CE count group by

I want to create a SQL query that will do the counting for me instead of in the razor code, I want to calculate the amount of distinct dates in my database. I found that SQL Server CE does not sup...

Show Detail

SQL Server Management Studio GROUP BY clause SHORTCUT

Is there is a shortcut or tool or something in T-SQL in SQL Server Management Studio that will allow you to automatically create a GROUP BY clause?

Show Detail

Get Formatted Date in SQL Server CE

How to get the formatted date in SQL Server CE? I have a column on a table that contains Date, but the column type is nvarchar ID Date ---------------------- 1 05/08/2012 2 10/08/20...

Show Detail

SQL Server CE exists clause performance

The following query runs very slow when running the sql against a SQL Server CE database, I had hoped to translate it to linq for EF. Can anyone advise on this, I haven't created any indexes on SQL

Show Detail

problem with SQL CE and orderby linq clause

I am using linq with SQL CE, but for a simple query like this: var points=from i in this.DomainBoundaryPoints orderby i.Index select i; I get this error: Could not find an implementation of the ...

Show Detail

SQL Server CE Application

I have written an application that I need to place on a SQL Server that pulls information from a SQL Server database and places it into a SQL Server CE database, however when I try to run it I get ...

Show Detail