關於查詢一張表中最小資料第一條

2021-09-25 23:11:16 字數 582 閱讀 5712

min()只是會取出指定列的最小資料,並不會使其成為乙個

如果表中最小資料重複,將全部取出

success

select min(linests) as linests

from

( select to_char(min(to_number(wsd.linests))) as linests

from wsodetail wsd

where 1 = 1

and wsd.socd = #

and wsd.del*** = 0

) where rownum = 1

在乙個表中查詢最小值:

在外面套一層再取第乙個,直接rownum =1資料將不準確

error

select to_char(min(to_number(wsd.linests))) as linests

from wsodetail wsd

where 1 = 1

and wsd.socd = #

and wsd.del*** = 0

and rownum = 1

同一張表中複製一條資料

insert into db exampl pid title img release id release time last edit time scene id brand id style id type describe group id is open status select pid...

分組查詢各組第一條記錄

我們在查詢資料的時候經常會遇到表中包含類似 型別 分組 等屬性字段。然後需要查詢出該分組下的第一條記錄。實現的sql如下 select name,link,type from select row number over partition by type order by name as row,...

查詢分組中每組第一條記錄組成的表

表xjgl id xh fenshu time xh表示 學號 fenshu表示分數 time表示時間 乙個xh也就是乙個學生對應多條記錄,但是我現在想查得每個學生最近一次的記錄,其它記錄都不要,有人想先將此表按學號分組,然後在每一組中取出第一條,組成乙個表 但是group by 不能完成此功能 可...