我有一张包含以下记录的表格:
BookingTimeStamp BookingReloc AEType
2016-01-14 23:19:24.773 LVWCQL Seat
2016-01-14 23:19:24.773 LVWCQL Seat
2016-01-14 23:19:24.773 LVWCQL Seat
2016-01-14 16:45:29.450 KCCEMG Baggage
2016-01-14 16:34:07.117 MEZYPN Insurance
2016-01-14 16:08:40.617 CJXDFK Insurance
2016-01-14 16:08:40.617 CJXDFK Insurance
2016-01-14 16:08:40.617 CJXDFK Insurance
2016-01-14 16:08:40.617 CJXDFK Insurance
2016-01-14 15:14:51.633 JMILRY Seat
我想计算AEType列中值的重复次数。
期望的输出:
Seat = 4
Baggaage = 1
Insurance =5
是否可以在单个查询中获取它?
答案 0 :(得分:1)
select AEType,count(*) from table_name
group by AEType;
答案 1 :(得分:1)
使用'group by'它通过distinct参数对sql条目进行分组,'count(*)'可用于计算每个不同AEType的sql条目数。
select AEType,count(*) from Table_Name group by AEType;