我有这个表,例如:
NUM1 BOX Status DATA
134813 119874 1 07.03.21
149950 119874 8 10.12.31
我想要做的是从表COMERT中选择,其中boxID = 119874,状态为1,但如果在表中有多行,则比较日期以查看状态1中的日期是否更多实际比其他人。如果它不返回任何东西。我怎么能这样做?
答案 0 :(得分:4)
select * from Comert
where boxID = 119874 and status=1
and date=(select max(date) from comert where boxID = 119874)