计算MYSQL

时间:2017-02-02 11:26:42

标签: mysql

我想计算表格中每个商品编号的出现次数。我的表格结构如下:

|customerNumber|OrderNumber|ArticleNumber|
|1|1|1|    
|2|2|2|    
|3|3|4|    
|1|4|3|    
|3|3|2|    
|4|5|2| 
|5|6|4|  

预期结果:

|ArticleNumber|NumberOfOrders|
|1|1|
|2|3|
|3|1|
|4|2|

我该怎么办? (我不知道atm)

2 个答案:

答案 0 :(得分:1)

您可以使用tablename语法select ArticleNumber,count(NumberOfOrders) as NumberOfOrders from tableName group by ArticleNumber 来满足您的要求。

现在,代码可以是,

.custom_chk  input[type="checkbox"] {
    display: none;
}
.custom_chk label {
    border: 1px solid #e9f8fb;
    padding: 16px;
    display: block;
    position: relative;
    cursor: pointer;
    -webkit-box-shadow: 1px 2px 3px -2px #999;
    -moz-box-shadow: 1px 2px 3px -2px #999;
    box-shadow: 1px 2px 3px -2px #999;
	margin-top: 15px;
	margin-bottom:10px;
	background: #FDFDFD;
	font-family: 'proxima_novaregular', Gotham, "Helvetica Neue", Helvetica, Arial, "sans-serif";
	font-weight: normal;
}
.custom_chk label::before {
    background-color: white;
    border: 1px solid #ff6d6d;
    color: white;
    content: " ";
    display: block;
    height: 25px;
    line-height: 28px;
    position: absolute;
    right: -2px;
    text-align: center;
    top: -2px;
    transform: scale(0);
    transition-duration: 0s;
    width: 25px;
}
.custom_chk :checked+label {
    outline: 2px solid #FF6D6D;
}
.custom_chk :checked+label:before {
    content: "\2713";
    background-color: #FF6D6D;
    transform: scale(0.9);
}

答案 1 :(得分:0)

您需要计算ArticleNumber然后使用以下查询

{{1}}