我想从数据库中检索所有行,其中1OWNERKEY
但只有DATAVERSION
.DATACONTROLID
在下面的示例中,我有两行DATACONTROLID
= 1,它们有 1 和 2 作为DATAVERSION
。我想达到最高。
数据库:
DATAKEY OWNERKEY OWNERTYPE DATAVERSION MALLKEY DATAVALUE DATAVALUETYPE DATACONTROLID DATADATE DATATIME DATASIGN
=========== ============ =========== =========== =========== ========= ============ ============= ========== =========== =========
4 1 2 1 1 1 2 1 2015-11-24 09:55:00:00 ADMIN
3 1 2 2 1 2 2 1 2015-11-23 20:55:00:00 ADMIN
2 1 2 1 1 3 2 2 2015-11-23 15:39:00:00 ADMIN
1 1 2 1 1 4 2 3 2015-11-23 11:29:00:00 ADMIN
想要的结果:
DATAKEY OWNERKEY OWNERTYPE DATAVERSION MALLKEY DATAVALUE DATAVALUETYPE DATACONTROLID DATADATE DATATIME DATASIGN
=========== ============ =========== =========== =========== ========= ============ ============= ========== =========== =========
3 1 2 2 1 2 2 1 2015-11-23 20:55:00:00 ADMIN
2 1 2 1 1 3 2 2 2015-11-23 15:39:00:00 ADMIN
1 1 2 1 1 4 2 3 2015-11-23 11:29:00:00 ADMIN
我从哪说起呢?
SELECT *
FROM MyDB
WHERE OWNERKEY = 1
上面的陈述是明显的部分,但我该如何着手呢?
我想我应该MAX(DATAVERSION)
以某种方式使用,但是要分组呢?我可以同时使用*
andMAX
吗?