我想数一下物品的数量 [英] I wish to count the number of items

查看:61
本文介绍了我想数一下物品的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://fbcdn-sphotos-ea.akamaihd.net/hphotos -ak-ash3 / t1 / 1743470_234921190024523_1305187537_n.jpg [ ^ ]



我希望计算此表中名为name=的列的项目数娃娃装

这里是我的查询:

https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-ash3/t1/1743470_234921190024523_1305187537_n.jpg[^]

I wish to count the number of items in this table where column named: "name" = "babydoll"
here is my query:

string query = ("select  count(name) as quantity, name, Product_Category, price, descriptions from Products where name = babydoll");

推荐答案

选择COUNT(名称)作为NameCount,名称来自Products的产品名称='babydoll'按名称分组
Select COUNT(name) as NameCount,name from Products where name='babydoll' group by name


试试这个
select  name,count(name) as quantity,Product_Category, price, descriptions from Products where name = 'babydoll'
group by name,Product_Category, price, descriptions



但是如果你需要带有它们的Product_Category,price,description列,那么你将获得多于一行的结果,因为这些列中的所有值都不相同

如果你想要你的名字你可以使用这个


but if you need the Product_Category, price, descriptions columns with them then you will get more then one row of result as all the values in these column are not same
if you want by name you can use this

select  name,count(name) as quantity from Products where name = 'babydoll'
group by name


你应该引用中的字符串子句:

You should quote the string in the where clause:
select  count(name) as quantity, name, Product_Category, price, descriptions from Products where name = 'babydoll'





请不要只获得一条记录,因为您使用的是 count ,这是一个聚合运算符。



Please not you are going to get just one record, because you are using count, that is an aggregate operator.


这篇关于我想数一下物品的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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