我在文本文件(2个表)中有一些混乱的数据。我想将它合并到1个表中,但存在重复问题。我的数据如下所示:
状态表
+--------------------------+
| | Last Name | Status | |
+--------------------------+
| | Jones | On Time | |
| | Jones | On Time | |
| | Jones | On Time | |
| | Jones | On Time | |
| | Jones | Missing | |
| | Hoinski | On Time | |
| | Hoinski | Late | |
| | Hoinski | Late | |
| | Hoinski | Missing | |
+--------------------------+
风险表
+-------------------------+
| | Last Name | Risk | |
+-------------------------+
| | Jones | High | |
| | Jones | High | |
| | Jones | Low | |
| | Jones | Medium | |
| | Jones | Medium | |
| | Jones | Medium | |
| | Jones | Medium | |
| | Smith | Low | |
| | Smith | Medium | |
| | Smith | Medium | |
| | Smith | Medium | |
| | Hoinski | High | |
| | Hoinski | High | |
| | Hoinski | Low | |
+-------------------------+
如何使用sql将这两个表聚合到一个表中?可能吗?我知道我没有适当的关系(很多很多)所以它没有多大意义。但是,如果我使用[姓氏]字段上的Group By语句汇总数据呢?
答案 0 :(得分:1)
您正确GROUP BY
将解决您的问题,此处是查询。
SELECT * FROM Status
INNER JOIN Risk ON Status.[Last Name] = Risk.[Last Name]
GROUP BY Status.[Last Name]
答案 1 :(得分:0)
使用 function swap()
{
var picture = document.getElementById('LaptopPicture');
if (picture.src === 'LaptopThin.jpg') {
picture.src = 'ServerRack.jpg';
} else {
picture.src = 'LaptopThin.jpg';
}
}
DISTINCT