Click here to Skip to main content
13,739,048 members
Rate this:
 
Please Sign up or sign in to vote.
See more: , +
Hello, Guys am working on c# and am facing an issue. "Additional information: Your query does not include the specified expression 'Item Name' as part of an aggregate function."
I don't know and I have tried many things but this error still there please help and tell me what is this and how can I resolve it
Thanks to Advance

What I have tried:

"    con_string.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0;Data Source =|DataDirectory|\Restaurant.accdb;Persist Security Info=False";
                            DataSet dsa = new DataSet();
                            DataTable dt = new DataTable();
                            dsa.Tables.Add(dt);
                            OleDbDataAdapter da = new OleDbDataAdapter();
                            da = new OleDbDataAdapter("SELECT sum(Column1) As [Item Price],[column2]As [Item Name],[column3]As [Table Name],[Flavours],[Customer Name],[Delivery Time],[Time] FROM Runtime Group by [column3]", con_string);
                            da.Fill(dt);
                            dataGridVaiew2.DataSource = dt;
                            con_string.Close();"
Posted 10-Nov-17 11:20am
Updated 10-Nov-17 19:50pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You need to include the list of columns in the GROUP BY clause which are available in the SELECT list and doesn't associated with an aggregate function.
Your query should look like-
SELECT sum(Column1) As [Item Price],[column2]As [Item Name],[column3]As [Table Name],[Flavours],[Customer Name],[Delivery Time],[Time] FROM Runtime Group by [column3],[column2],[Flavours],[Customer Name],[Delivery Time],[Time]


But the result you will get probably is not what you expected. You need to include only those columns which are essentially needed.

Please let me know with a sample output in that case so that I can help further.

Thanks :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180920.1 | Last Updated 11 Nov 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100