HQL查詢中取個別幾個字段

2021-09-07 05:19:30 字數 901 閱讀 8472

資料表:

要求:查詢type為4001,以content分組,本計算不重複的pcinfoid

mysql語句:

select

count(distinct pcinfoid) as

count,content,time from vrv_paw_reportlog where type=

'4001

'group

by content

對應的hql語句:

select  new map(count(distinct this.pcinfo.id) as

count,this.content as content,this.time as

time)

from

com.vrv.paw.domain.reportlog this

where this.type=

4001

group

by this.content

注:使用關鍵字as

給「被選擇了的表示式」指派別名:

select max(bodyweight) as max, min(bodyweight) as min, count(*) as n

from cat cat

這種做法在與子句select new map

一起使用時最有用:

select new map( max(bodyweight) as max, min(bodyweight) as min, count(*) as n )

from cat cat

該查詢返回了乙個map

的物件,內容是別名與被選擇的值組成的名-值對映

這樣可以方便產生json字元

我犯的乙個錯誤:

TCP 幾個字段含義

1 tcp out of order tcp有問題 2 tcp segment of a reassembled pdu 3 tcp previous segment lost tcp先前的分片丟失 4 tcp acked lost segment tcp應答丟失 5 tcp window upda...

不同資料庫取前幾個欄位的方法

1.oracle select from table1 where rownum n 2.informix select first n from table1 3.db2 select row number over order by col1 desc as rownum where rownu...

Linq中查詢乙個表中指定的幾個字段

var ts t.findallitems where p p.companyid cursiteuser.companyid select s new distinct tolist orderbydescending s s.billperiod take 24 findallitems 為查詢...