我是一名学生开发人员,目前正在学习 SQL 课程。我目前正在尝试从表中检索几组行的总和。我对 SQL 开发非常陌生,我不太确定以下场景中的问题是什么。我有一个大表,我想从中选择特定行,然后添加余额列。
以下不会在结果中显示任何数据,我不太清楚为什么。我有一种预感,每个表之间只能使用一次 between 语句,但也许我错了?
Select Description, SUM(Balance) AS Total_Balance
FROM Chart_Of_Accounts
WHERE (Account BETWEEN ('400401') AND ('400407'))
AND (Account BETWEEN ('440094') AND ('440100'))
AND (Account BETWEEN ('450094') AND ('450100'))
GROUP BY Description, Balance
编辑 10.1.2012 应(Richard aka cyberkiwi) 的要求
是)我有的
Set 1
|Account |Description |Balance
|4004xx |Red Wine |$2361.23
|4004xx |White Wine |$3620.23
|4004xx |Rice Wine |$1223.23
Set 2
|Account |Description |Balance
|4400xx |Red Wine |$4361.23
|4400xx |White Wine |$3260.23
|4400xx |Rice Wine |$223.23
Set 3
|Account |Description |Balance
|4500xx |Red Wine |$1361.23
|4500xx |White Wine |$1620.23
|4500xx |Rice Wine |$1223.23
我正在努力实现的结果
Total
|Description |Total_Balance
|Red Wine |$8083.69
|White Wine |$8500.69
|Rice Wine |$2669.69
感谢您阅读我的帖子!我也愿意接受任何关于 SQL 开发的建议,非常感谢任何反馈。