Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I have create datatable in that datatable columns are like 1_A,2_B,...
Problem to calculate summary of that datatable. Exception is "Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier."

eg.
DateTime _min = Convert .ToDateTime (ds.Tables["dsSlno"].Compute("Max(2_B)",null));

help me.

Regards,
Om
Posted
Comments
Maciej Los 28-Mar-13 7:31am    
Which database: ms access, ms sql server, mysql?

I just tried your code using a DB I had to hand:
C#
SqlConnection con = new SqlConnection(@"Data Source=GRIFFPC\SqlExpress;Initial Catalog=VideoMaster;Integrated Security=True");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Videos", con);
DataTable dt = new DataTable();
da.Fill(dt);
DateTime dat = (DateTime)dt.Compute("MAX(InsertDate)", null);
DateTime dat2 = Convert.ToDateTime(dt.Compute("MAX(InsertDate)", null));
Both dates were correct and valid. So, what am I doing that is different from you?
 
Share this answer
 
To read minimum value from your database use MAX() function in query than read it using Command to DataSet or DataTable object.

MS SQL:
http://msdn.microsoft.com/pl-pl/library/ms187751.aspx[^]
http://msdn.microsoft.com/en-us/library/ms179916.aspx[^]
MySQL:
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_max[^]
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_min[^]

MS Access:
http://office.microsoft.com/pl-pl/access-help/funkcje-min-i-max-HP001032255.aspx[^]

SQL
SELECT Department, MIN(EmpID)
FROM YourTable
GROUP BY Department
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900