组功能的使用无效 [英] Invalid use of group function

查看:77
本文介绍了组功能的使用无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我提前谢谢

错误是: - 无效使用群组功能

Pls help me thanks in advance
error is:- Invalid use of group function

public DataTable Search(int accountid, DateTime start, DateTime end,decimal amount)
    {
        try
        {
            string qry = "select * from Account where date >=@start and date <=@end and accountid=@accountid and sum(amount)=@amount";
            MySqlParameter startP = new MySqlParameter("@start", start);
            MySqlParameter endP = new MySqlParameter("@end", end);
            MySqlParameter accountidP = new MySqlParameter("@accountid", accountid);
            MySqlParameter amountP=new MySqlParameter("@amount",amount);
            MySqlParameter[] p = { startP, endP, accountidP, amountP };
            return MySqlHelper.ExecuteDataset(Common.GetConnectionString(), qry, p).Tables[0];
        }
        catch
        {
            Exception ex = new Exception(" Search AccountDetail Error.");
            throw ex;
        }

推荐答案





你要去使用聚合函数Sum但你没有使用group by。

这就是错误发生的原因。



完整参考: http://msdn.microsoft.com/en-us/library/aa258901(v = sql.80).aspx [ ^ ]



但在你的情况下,我认为子查询将有用,或内联分组:)
Hi,

You are going to use aggregate function "Sum" but you did not use group by.
That''s why the error occur.

For complete reference : http://msdn.microsoft.com/en-us/library/aa258901(v=sql.80).aspx[^]

but in your case I think sub query will helpful, or inline grouping :)


这篇关于组功能的使用无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆