houdongen 发表于 2023-9-26 16:29:25

总数语句格式

您好:

       select o.xcode,xname=d.xproductName,xcun=sum(o.xnumber - b.xselectSum),ying=sum(o.xnumber)

FROM QRY_DYN_ORDERINFO o
INNERJOIN QRY_DYN_SENDANDRECEIVEINFORMATION b
ON o.xcode=b.xorderFormCode
INNERJOIN QRY_DYN_PRODUCTTABLE d
ON o.xproductName = d.xcode
group by o.xcode,d.xproductName
以上是查询语句
以下是指定总数语句,格式是不是有误,报错了
SELECT COUNT(*) AS TotalCount
FROM (
    SELECT o.xcode,xname=d.xproductName,xcun=sum(o.xnumber - b.xselectSum),ying=sum(o.xnumber)
    FROM QRY_DYN_ORDERINFO o
    INNERJOIN QRY_DYN_SENDANDRECEIVEINFORMATION b
    ON o.xcode=b.xorderFormCode
    INNERJOIN QRY_DYN_PRODUCTTABLE d
    ON o.xproductName = d.xcode
    group by o.xcode,d.xproductName
) AS subquery

论坛管理员 发表于 2023-9-27 09:32:20

指定总数语句在哪儿?没看见,报错截图发出来,格式乱了看不出来
另外您使用的原生sql语句吧,如果语句报错,可以先去数据库连接工具里试试看您的sql语句是否正确

houdongen 发表于 2023-9-27 15:28:29

论坛管理员 发表于 2023-9-27 09:32
指定总数语句在哪儿?没看见,报错截图发出来,格式乱了看不出来
另外您使用的原生sql语句吧,如果语句报错 ...

语句没问题的,总数语句忽略可以执行,现在想使用分页,指定语句应该怎样写,例子里面是SELECT count(o.id) FROM TaskCompleted o,,那聚合函数,应该返回什么呢....

论坛管理员 发表于 2023-9-27 16:25:07

一样,跟您查询的条件一样的,然后返回总数,这个总数是用于视图分页的

houdongen 发表于 2023-9-27 19:18:29

本帖最后由 houdongen 于 2023-9-27 19:21 编辑

论坛管理员 发表于 2023-9-27 16:25
一样,跟您查询的条件一样的,然后返回总数,这个总数是用于视图分页的
您好:

      总数语句,sql语句在 数据库工具均可执行,
平台报错,忽略又正常,查询到的总数确实是2条,总数语句如下


SELECT COUNT(*) AS 行数 FROM (
SELECT d.xcode AS 订单编号,
e.xcustomerName AS 客户名称,
b.xproductName AS 产品名称,
d.xnumber AS 订单数量,
d.xprice AS 报价单价,
isnull(sum(o.xselectSum), 0) AS 已入库,
isnull(sum(o.xweekday), 0) AS 已发货,
(isnull(d.xnumber, 0) - isnull(sum(o.xweekday), 0)) AS 待发货,
(isnull(d.xnumber, 0) - isnull(sum(o.xselectSum), 0)) AS 待入库,
(isnull(d.xprice, 0) * isnull(sum(o.xweekday), 0)) AS 应付款,
isnull(aa.已付款, 0) AS 已付款,
(isnull(d.xprice * sum(o.xweekday), 0) - isnull(aa.已付款, 0)) AS 待付款
FROM QRY_DYN_ORDERINFO d--dingdan
LEFT JOIN QRY_DYN_SENDANDRECEIVEINFORMATION o--shoufa
ON o.xorderFormCode = d.xcode
AND o.xstate = '审核'
LEFT JOIN QRY_DYN_PRODUCTTABLE b--chanpin
ON d.xproductName = b.xcode
LEFT JOIN QRY_DYN_CUSTOMERTABLE e--kehu
ON d.xcustomerName = e.xcustomerId

LEFT JOIN(
SELECT f.xorderFormCode, SUM(f.xselectSum) AS 已付款 FROM QRY_DYN_FINANCIALINFORMATION f GROUP BY f.xorderFormCode
) AS aa ON aa.xorderFormCode = d.xcode
GROUP BY d.xcode, d.xnumber, b.xproductName, e.xcustomerName, d.xprice, aa.已付款
) AS 结果集

论坛管理员 发表于 2023-9-28 09:25:19

您是什么版本的o2server?

houdongen 发表于 2023-9-28 10:04:54

论坛管理员 发表于 2023-9-28 09:25
您是什么版本的o2server?

8.1.1版本,官网下载的

xadmin 发表于 2023-10-7 09:35:41

houdongen 发表于 2023-9-28 10:04
8.1.1版本,官网下载的

总数语句不支持groupBy

houdongen 发表于 2023-10-7 11:11:29

xadmin 发表于 2023-10-7 09:35
总数语句不支持groupBy

SELECT count(xid) FROM QRY_DYN_ORDERINFO(最左的表),这样也不对,class java.lang.Integer cannot be cast to class java.lang.Long java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap)
页: [1]
查看完整版本: 总数语句格式