Select max in SQL Server 2008 R2 using C# -
this question has answer here:
i'm getting error
column invalid in select list because not contained in either aggregate function or group clause.
actually code works in mysql database using sql server 2008 r2 now. please me
this code:
class1.sqlstatement = "select max(tix), dealer, module, uname, dept, prob, pic, recieved, dresolved, stamp, tresoved, aging, typee, status, assigned, stat, root, remarks, deploystat, reply tblhd group tix having max(tix) > 19999"; class1.dbcommand = new sqlcommand(class1.sqlstatement, class1.dbconnection); class1.reader = class1.dbcommand.executereader(); while (class1.reader.read()) { lstitem = listview1.items.add(class1.reader[0].tostring()); lstitem.subitems.add(class1.reader[1].tostring()); lstitem.subitems.add(class1.reader[2].tostring()); lstitem.subitems.add(class1.reader[3].tostring()); lstitem.subitems.add(class1.reader[4].tostring()); lstitem.subitems.add(class1.reader[5].tostring()); lstitem.subitems.add(class1.reader[6].tostring()); lstitem.subitems.add(class1.reader[7].tostring()); lstitem.subitems.add(class1.reader[8].tostring()); lstitem.subitems.add(class1.reader[9].tostring()); lstitem.subitems.add(class1.reader[10].tostring()); lstitem.subitems.add(class1.reader[11].tostring()); lstitem.subitems.add(class1.reader[12].tostring()); lstitem.subitems.add(class1.reader[13].tostring()); lstitem.subitems.add(class1.reader[14].tostring()); lstitem.subitems.add(class1.reader[15].tostring()); lstitem.subitems.add(class1.reader[16].tostring()); lstitem.subitems.add(class1.reader[17].tostring()); lstitem.subitems.add(class1.reader[18].tostring()); lstitem.subitems.add(class1.reader[19].tostring()); }
in sql server not allowed, since you're asking fields not contained in group clause or in aggregate function, max. way put of requested fields in group clause
Comments
Post a Comment