- 论坛徽章:
- 0
|
请教一个简单的SQL查询的问题
呵呵!你说的没错。下面这种方法行不行呢?
- SQL>; select * from cj;
- ID XH XQ KC CJ LB
- ---------- -------- ------------- -------------------- ---------- -
- 1 00520113 2002-2003(1) computer 95 1
- 2 00520113 2002-2003(1) VFP 75 2
- 3 00520113 2002-2003(1) VFP 67 3
- 4 00520113 2002-2003(1) computer 80 2
- 5 02510322 2002-2003(1) VFP 89 1
- 6 02510322 2002-2003(1) VFP 67 3
- 已选择6行。
- SQL>; select x.id,x.xh,x.xq,x.kc,x.cj,x.lb from cj x join (select xh,xq,kc,max(cj) cj
- 2 from cj group by xh,xq,kc) y on x.cj=y.cj and x.xh=y.xh and x.kc=y.kc
- 3 and x.xq=y.xq;
- ID XH XQ KC CJ LB
- ---------- -------- ------------- -------------------- ---------- -
- 2 00520113 2002-2003(1) VFP 75 2
- 1 00520113 2002-2003(1) computer 95 1
- 5 02510322 2002-2003(1) VFP 89 1
复制代码 |
|