我需要从视图中选择所有记录,但在一列上选择。该视图有很多列,因此我不想在查询中的所有列之前放置该区域;他们可能会增加
e.g。
post_code name last_name col_a col_b col_c col_d col_e col n...
A1 123 Abi Smith a a a a a
A1 123 Barb BarbLastName b c d b c
B1 123 Cart CartLastName b c d b c
C3 123 Dilbert DilberLastName b c d b c
D4 123 Edgar EdgarLastName b c d b c
D4 123 Fred FredLasName b c d b c
所以类似于通过不同的邮政编码选择*记录并返回所有第一个(或任何)
A1 123 Abi Smith a a a a a
B1 123 Cart CartLastName b c d b c
C3 123 Dilbert DilberLastName b c d b c
D4 123 Fred FredLasName b c d b c
由于
答案 0 :(得分:3)
如何选择所需的行?
您可以使用select t.*
from (select t.*,
row_number() over (partition by post_code order by dbms.random) as seqnum
from (<your query here>) t
) t
where seqnum = 1;
获取任意行:
cycleDates(){
const min = 0;
const max = 3;
const idx = this.randomIntBetween(min,max);
this.setState({
cacheTimestamps: this.state.cacheLotery[ idx ],
dataSource: this.ds.cloneWithRows(['ABCD','EFGH','IJKL']),
}, ()=> console.log('dbug cycleDates, new index [%i] and cacheTimestamps Object is %O', idx, this.state.cacheTimestamps));
}