选择总和问题 [英] select sum question

查看:53
本文介绍了选择总和问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Access和SQL的新手。我试图在Access中编写一个返回列的值总和的查询。查询工作正常,唯一的问题是,如果没有值,则返回空。我希望在这种情况下返回零值。


我的虚拟DummyTable表有两列:

1.价格

2.日期


我的查询如下:

Hi, I''m a newbie in Access and SQL. I am trying to write a query in Access that returns the sum of values on a column. The query works fine, the only problem is that if there are no values it return empty. I would like to return value zero in this situation.

My dummy DummyTable table has two columns:
1. Price
2. Date

My query looks like:

展开 | 选择 | Wrap | 行号

推荐答案

您好Cristian,


(删除原始帖子更正)


确保您的Price字段的默认值设置为0 。


您需要将字段日期重命名为其他内容,因为日期是Access中的保留字。


使用Dsum()函数而不是Sum()。 Dsum()函数有两个必需的expr和domain参数。在M
Hi Cristian,

(Deleted original post to correct)

Make sure the default value of your Price field is set to 0.

You will need to rename your field Date to something else, as Date is a reserved word in Access.

Use the Dsum() function instead of Sum(). The Dsum() function has two required arguments of expr and domain. Look it up in M


帮助文件中查找详细信息。


我在测试数据库中使用了它,它返回了所需的0数字。 br />

如果这对你不起作用,请发布你正在使用的sql代码。


问候,

Scott
helpfile for the specifics.

I used this in my test db, and it returned the 0 figure desired.

If this doesn''t work for you please post the sql code you are using.

Regards,
Scott


这里也是一个很好的基本sql语法教程:

基本SQL语法


问候,

Scott
Here is also an excellent basic sql syntax tutorial:

Basic SQL syntax

Regards,
Scott


这篇关于选择总和问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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