1

我已将一个大型 CSV 文件导入到表中。表格示例如下所示

name,      eye,point,field,date,seconds,sensitivity*10,slope,intercept,T*1000

NESSA SONIA ,R,6,4,08-04-09,32658845,160,1.062300e+001,62538,  1282
NESSA SONIA ,R,6,5,20-05-09,36288632,20, 5.360101e+000,64036,   771
NESSA SONIA ,R,6,6,02-12-09,53223062,60, 3.425260e+000,64590,   767
NESSA SONIA ,L,6,4,08-04-09,32658922,230,4.629489e+000,64382,   582
NESSA SONIA ,L,6,5,20-05-09,36288515,170,2.805373e+000,64901,   511
NESSA SONIA ,L,6,6,02-12-09,53223059,220,3.528252e+000,64694,  1022

我必须将右眼和左眼“灵敏度 * 10”值与匹配点和字段值进行比较并提取最高值(我的意思是行)。

例如,我必须比较第一行和第四行,因为点、字段和日期相同,并提取第四行,因为灵敏度最高。我有一个巨大的文件,需要提取所有值。任何人都可以帮助使用 sql 查询,将不胜感激。

4

3 回答 3

1
(select  `table l`.*  from `table l`, `table r` 
where `table l`. `sensitivity*10` > 10 and `table l`.`sensitivity*10`>`table r`.`sensitivity*10`) 

union 

(select  `table r`.* from `table r`, `table l` 
where `table r`. `sensitivity*10` > 10 and `table r`.`sensitivity*10`>`table l`.`sensitivity*10`)
于 2012-05-09T02:07:23.253 回答
0

您需要使用 SQLMAX()函数和GROUP BY名称。

尝试这样的事情:

SELECT  *
FROM    (
    SELECT  point, field, MAX(sensitivty*10) AS max
    FROM    table
    GROUP BY
            name
    ) tbl
JOIN    table
ON      table.point = tbl.field

另外,请查看其他 Stackoverflow Q&A,它的查询类似于您感兴趣的查询:SQL Group by & Max

于 2012-05-06T15:00:34.027 回答
0

我认为这应该适合你:

select if(t1.sensitivity*10 > t2.sensitivity*10,t1.sensitivity*10,t2.sensitivity*10) as col1  
from table t1 
inner join table t2 
    on  t1.field = t2.field 
    and t1.point = t2.point 
    and t1.date = t2.date 
where t1.eye ='R' and t2.eye ='L'   
于 2012-05-06T16:09:04.507 回答