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」の値を、一致するポイントとフィールドの値と比較して、最も高い値(つまり行)を抽出する必要があります。

たとえば、ポイント、フィールド、日付が同じであるため、最初の行と4番目を比較し、感度が最も高いため、4番目を抽出する必要があります。巨大なファイルがあり、すべての値を抽出する必要があります。誰でも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

MAX()SQL関数と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 に答える