create table oness( oids number(4) PRimary key, Names varchar2(10) not null, Email varchar2(20), LastLogin date);添加的數(shù)據(jù)如下:
查詢出test4、test1、test2用戶最近的登錄記錄有兩種方式:
第一種:
select%20*%20from%20oness%20awhere%20not%20exists(select%201%20from%20oness%20where%20Names%20=%20a.Names%20and%20LastLogin%20>%20a.LastLogin);查詢結(jié)果為:
第二種:
select%20*%20from%20oness%20a%20where%20LastLogin=(select%20max(LastLogin)%20from%20oness%20where%20Names=a.Names);查詢結(jié)果為:
以上兩種方式查詢基本一樣,都可以,只不過(guò)查詢后的結(jié)果順序不同。
新聞熱點(diǎn)
疑難解答
圖片精選