SQL查询,子查询作为结果字段

SQL查询,子查询作为结果字段,

SELECT DISTINCT
	sp.comcode,
	sp.projectname,
	sp.projecttime,
	sp.busnature,
	sp.bustype,
	sl.concode,
	sl.conname,
	sl.contype,
	sl.conpartya,
	sl.contotal,
	sl.conrisedate,
	sl.constopdate,
	sl.contotalperiod,
	(
		SELECT
			SUM(chargemoney)
		FROM
			sab_b_conpay sc
		WHERE
			sc.concode = sl.concode
		GROUP BY
			sc.concode
	) AS chargemoney000,
	(
		SELECT
			SUM(confirmamount)
		FROM
			sab_b_conpay sc
		WHERE
			sc.concode = sl.concode
		GROUP BY
			sc.concode
	) AS confirmamount000,
	(
		SELECT
			SUM(noconfirmamount)
		FROM
			sab_b_conpay sc
		WHERE
			sc.concode = sl.concode
		GROUP BY
			sc.concode
	) AS noconfirmamount000
FROM
	sab_b_ledger sl
LEFT JOIN sab_b_project sp ON sl.projectcode = sp.projectcode
  • 2
    点赞
  • 1
    评论
  • 3
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值