显示字段中值的总计
下午好。我在想是否有可能显示表中选定字段的总和或总计以及与日期的关系:
例如我想知道我的酒店每月的啤酒总消耗量。
我这里有我的服务表:
[services_id[pk],
customer_id[fk],
date_in,date_out,room_type,room_number,
extra_ref,
extra_bed,extra_snack,
extra_beer,extra_softdrinks,
extra_pillows,extra_breakfast,
extra_snack_q,
extra_beer_q,
extra_softdrinks_q,
extra_pillows_q,
extra_breakfast_q]
您能给我一些关于如何获得它的建议吗? 提前致谢:
-renz
good pm. i was thinking is it possible to show the summation or grand total of a selected field in the table and with relation to date:
for example is i want to know the total beer consumption of my hotel every month.
i have here my table on services:
[services_id[pk],
customer_id[fk],
date_in,date_out,room_type,room_number,
extra_ref,
extra_bed,extra_snack,
extra_beer,extra_softdrinks,
extra_pillows,extra_breakfast,
extra_snack_q,
extra_beer_q,
extra_softdrinks_q,
extra_pillows_q,
extra_breakfast_q]
can you give some advice on how can i get it.
thanks in advance:
-renz
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
[额外信息]
另外,我认为组织此表的最佳方法是将其分成几个其他表。将客户信息存储在第一个表中,例如
,并有另一个名为 room_items 的表,其中包含以下内容,
然后另一个名为 room_purchases 的表,其中包含以下内容,
这将帮助您对所有三个表进行联接,它们将以这种方式更加规范化。
[EXTRA INFO]
Also I believe that the best way to organize this table is to separate out this table into a few other tables. Store customer info in the first table such as
And have another table named something like room_items which would have the following,
And then another table named room_purchases which will have the following,
This would help you to do a join on all three tables and they would be more normalized in this way.
这将返回如下内容:
如果您想根据日期限制查询,只需在
GROUP BY
之前添加一个WHERE
约束this will return something like this:
if you want to limit the query depending on the date just add a
WHERE
constraint before theGROUP BY