0

我正在研究鱼的生长速度,所以每次测量一条鱼时我都需要拉体重和日期。

现在每个捕获记录都在单独的行上。我基本上想从这个表中拉出pitcode, species, tagdate1, length1, weight1, tagdate2, length2, weight2,tagdate3等。我正在使用 Microsoft Access。提前感谢您的任何建议。pitcodetagdate

pitcode         tagdate       length  weight    species
3D9.1C2D9C7FCE  7/26/2011   213 118 3
3D9.1C2D9F3AB2  7/26/2011   148 38  3
3D9.1C2D9F1627  7/26/2011   215 116 3
3D9.1C2D60CDC6  7/26/2011   165 58  3
3D9.1C2D9F0797  7/26/2011   244 204 3
3D9.1C2D9BA47F  7/26/2011   143 47  3
3D9.1C2D9FD674  7/27/2011   226 183 3
3D9.1C2DA1C597  7/27/2011   123 27.2    3
3D9.1C2D9FE09F  7/27/2011   241 182.3   3
3D9.1C2D9FE4D8  7/27/2011   286 301 3

我从另一篇文章中找到了这个“自我加入”,它有效:

SELECT
  a.pitcode, 
  MIN(a.tagdate) AS td1, MIN(b.tagdate) AS td2, 
  MIN(a.weight) AS wt1, MIN(b.weight) AS wt2
FROM
  tagd a
  LEFT JOIN tagd b
  ON a.pitcode = b.pitcode AND b.tagdate > a.tagdate and b.weight>a.weight
GROUP BY
  a.pitcode;
4

0 回答 0