如何在sql中计算产品 [英] how to count product in sql

查看:93
本文介绍了如何在sql中计算产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我在表中使用了8个类别..



每个类别都包含很多产品.....





如何计算sql中的产品......





i是使用2个表格的分类表和产品表



例如



类别



tomoto(5)

orange(8)

apple(4)





请有人帮我解决SQL查询

now i was using 8 category in the table..

each category include a many product.....


how to count a product in sql...


i was using 2 table a categorytable and product table

for example

category

tomoto(5)
orange(8)
apple(4)


please anybody help me in sql query

推荐答案

在不知道您的确切表定义和样本数据的情况下,我们不能给你一个确切的答案。

但它可能与

Without knowing your exact table definitions, and sample data, we can't give you an exact answer.
But it's probably along the lines of
SELECT p.Name, Count(c.ID) FROM Products p
JOIN Categories c
ON p.CategoryID = c.ID
GROUP BY p.Name


这篇关于如何在sql中计算产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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