【发布时间】:2017-08-28 14:48:45
【问题描述】:
我有一个类别列表,我可以使用 select distinct 语句,但很难“计算”一个类别的使用次数,我有一个名为 Description 的列,我需要创建另一个名为occurrence 的列。
Description
-------------
Arts, crafts, and collectibles
Baby
Beauty and fragrances
Books and magazines
Business to business
Clothing, accessories, and shoes
Computers, accessories, and services
Education
Electronics and telecom
Entertainment and media
Financial services and products
Food retail and service
Gifts and flowers
Government
Health and personal care
Home and garden
Nonprofit
Pets and animals
Religion and spirituality (for profit)
Retail (not elsewhere classified)
Services - other
Sports and outdoors
Toys and hobbies
Travel
Vehicle sales
Vehicle service and accessories
Books and magazines
Business to business
Clothing, accessories, and shoes
Computers, accessories, and services
Education
Electronics and telecom
Entertainment and media
Financial services and products
Food retail and service
Gifts and flowers
Government
Health and personal care
Services - other
Sports and outdoors
Toys and hobbies
Travel
Vehicle sales
Vehicle service and accessories
Books and magazines
Business to business
Clothing, accessories, and shoes
Business to business
Clothing, accessories, and shoes
Computers, accessories, and services
Education
Electronics and telecom
Entertainment and media
Financial services and products
Food retail and service
【问题讨论】:
-
你可以使用
count(1)和group by的组合 -
向我们展示您的查询并准确解释为什么输出不是您想要的以及为什么您认为您的查询会产生它。
-
向我们展示数据库架构、示例数据、当前和预期输出。请阅读How-to-Ask 这里是START 了解如何提高问题质量并获得更好答案的好地方。 How to create a Minimal, Complete, and Verifiable example
标签: sql sql-server reporting-services