hql 查詢非group by欄位

2021-08-27 19:58:21 字數 556 閱讀 9454

1.取得非group by 字段

select collect_list(event) , uuid from stat_event group by uuid;

2.得到事件流(自定義事件處理)

select cid, uuid, account, concat_ws(',', collect_list(cast (event as string) ) ), concat_ws(',', collect_list(cast (timestamp as string) ) ) from stat_event where year = 2015 and month = 1 and day = 5 group by cid, uuid, account;

總結:

collect_list(event):會得到乙個 完整的 事件序列(未排序的)

collect_set(event):會得到乙個  去重的 事件序列 (未排序的)

concat_ws(',' ,  collect_list(cast (event as string) ) )  :事件按照逗號分隔,組成乙個事件流字串

Hibernate中用hql查詢部分字段

在hibernate中,用hql語句查詢實體類,採用list方法的返回結果為乙個list,該list中封裝的物件分為以下三種情況 1.查詢全部欄位的情況下,如 from 實體類 list中封裝的物件為實體類本身,各屬性都將得到填充。2.只查詢乙個字段,預設情況下,list中封裝的是object物件。...

資料庫 group by查詢出其他字段

create table lsq test table id varchar 64 not null comment 主鍵 name varchar 10 comment 姓名 class varchar 10 comment 班級 yuwen varchar 10 comment 語文 shuxu...

group by 多個字段

網上查了很多好像說的都對,但是囉嗦,我看著都費勁 在現實的應用場景中 如果想要統計每個班的男生 女生的數量就可以group by 班級id,性別 如下 select class.name case when students.1 then 男 else 女 end as 1,count studen...