select distinct cont_id from cms_contentiteminfo t order by cast (t.click as int) desc
上面這句報錯ORA-1791,not a SELECTED expression
select distinct cont_id ,cast (t.click as int) as c from cms_contentiteminfo t order by cast (t.click as int) desc
查出的結果是有重複記錄的
cont_id c
185337 1517
185639 1003
185586 985
185337 967
185641 937
185337 899
185639 832
185641 832
185641 727
185283 649
185144 605
185586 588
185639 564
185216 547
185586 508
185283 492
185144 422
185283 421
185216 378
185217 369
185144 346
185626 309
185217 303
192278 254
修改爲
select distinct cont_id,max(cast (t.click as int)) c from cms_contentiteminfo t group by cont_id order by c desc
查詢結果
cont_id c
185337 1517
185639 1003
185586 985
185641 937
185283 649
185144 605
185216 547
185217 369
185626 309
192278 254
185145 234
191809 214
185286 191
190484 190
185642 190
190487 180
185287 171
190486 162
192483 146
189151 138
191253 118
177607 117
192704 116
185140 115
cont-id重複的記錄就可以去掉了