计算更改的数据

时间:2017-08-03 14:23:07

标签: sql

我有一个数据,我需要给出置信代码更改的行数。

输入数据:

ID Date  ReMatchConfidence OrgMatch
1  2017      101             45
2  2017      101             88
3  2017      103             35
4  2016      104             66
5  2016      104             66
6  2017      104             66
7  2016      88              14
8  2017      88              25

输出:

Data                   2017 2016
Change from 45 to 101   1   0
Change from 88 to 101   1   0
Change from 35 to 103   1   0
Change from 66 to 104   1   2
Change from 14 to 88    0   1
Change from 25 to 88    1   0

2 个答案:

答案 0 :(得分:0)

试试这个:

SELECT CONCAT('Change from ', OrgMatch, ' to ', ReMatchConfidence) AS Data,
Count(IF(Date = '2017', 1, NULL)) as '2017', 
Count(IF(Date = '2016', 1, NULL)) as '2016' 
FROM tables GROUP BY OrgMatch, ReMatchConfidence;

答案 1 :(得分:0)

对Daria的查询稍加修改。适用于SQL Server

<div class="dialog-box" align="center">
    <h1 md-dialog-title>Order Fields</h1>
    <div class="pull-right">
        <md-icon (click)="moveFieldUp()" class="order-button hover-theme-primary">expand_less</md-icon>
        <br />
        <md-icon (click)="moveFieldDown()" class="order-button move-field-down hover-theme-primary">expand_more</md-icon>
    </div>

    <md-button-toggle-group *ngIf="showButtonToggleGroup" [vertical]="true">
        <ng-container *ngFor="let field of fieldsTable; let i = index">
            <md-button-toggle class="toggle-button" id="button-toggle-{{i}}" (click)="onSelect(i)" *ngIf="!field.IsKey" value={{i}}>
                {{field.Name}} 
            </md-button-toggle>
        </ng-container>
    </md-button-toggle-group>

    <md-dialog-actions align="center">
        <button md-raised-button (click)="dialogRef.close('Cancel')">Close</button>
    </md-dialog-actions>
</div>