This is my existing table
这是我现有的表格
ID Patient Study AVA LVOT LV AVPG
AA11 11 3 0 12 0 0
AA11 11 3 0 0 123 0
AA11 11 3 0 0 0 456
AA11 11 3 902 0 0 0
AA12 12 4 0 0 10 0
AA12 12 4 90 0 0 0
AA12 12 4 0 34 0 0
AA12 12 4 0 0 0 18
and this is my required output all values in single row how this can be done
这是我所需的输出单行中的所有值如何做到这一点
ID Patient Study AVA LVOT LV AVPG
AA11 11 3 902 12 123 456
AA12 12 3 90 34 10 18
1 个解决方案
#1
1
Assuming all your values are positive, this should do what you want:
假设你的所有价值观都是积极的,这应该做你想要的:
SELECT t.ID, t.Patient, t.Study,
SUM(t.AVA) as AVA, SUM(t.LVOT) as LVOT, SUM(t.LV) as LV, SUM(t.AVPG) as AVPG
FROM table t
GROUP BY t.ID, t.Patient, t.Study;
You don't mention the specific database you are using, but this is standard SQL and should work in any database.
您没有提到您正在使用的特定数据库,但这是标准SQL,应该可以在任何数据库中使用。
#1
1
Assuming all your values are positive, this should do what you want:
假设你的所有价值观都是积极的,这应该做你想要的:
SELECT t.ID, t.Patient, t.Study,
SUM(t.AVA) as AVA, SUM(t.LVOT) as LVOT, SUM(t.LV) as LV, SUM(t.AVPG) as AVPG
FROM table t
GROUP BY t.ID, t.Patient, t.Study;
You don't mention the specific database you are using, but this is standard SQL and should work in any database.
您没有提到您正在使用的特定数据库,但这是标准SQL,应该可以在任何数据库中使用。