[英]Grouping of data
I have a database that records clients who have a rating score upon entry of the service we provide, this is between 0 - 50, they are seen on average once a week and after four sessions they are re-evaluated on the same score to see a trend so say initially they may score 22 and after four weeks it may be 44 What i am after is a sql query to group this data 我有一个数据库,该数据库记录了在我们提供的服务进入时获得评分的客户,该评分介于0到50之间,他们平均每周见一次,经过四次会议后,他们会根据相同的评分重新评估一个趋势,所以说最初他们可能会获得22分,而四个星期后可能是44分,我追求的是一个将数据分组的sql查询
+----+-------+--------+
|name|initial|followup|
+----+-------+--------+
|joe |22 | |
+----+-------+--------+
|joe | |44 |
+----+-------+--------+
i want this to show 我想要这个显示
+----+-------+--------+
|name|initial|followup|
+----+-------+--------+
|joe |22 |44 |
+----+-------+--------+
i know this is a simple question and have done this before but tis the time of the year and the pressure is on from management many thanks in advance 我知道这是一个简单的问题,以前已经做过,但是一年中的时间还很久,管理层的压力越来越大,在此先感谢
Assuming the -
means NULL
, just use aggregation: 假设-
表示NULL
,则使用聚合:
select name, max(initial) as initial, max(followup) as followup
from t
group by name;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.