|  |  |  | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, COUNT(*) AS openCount | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | SELECT client_id, COUNT(*) AS openCount | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="openCount != null and openCount > 0"> | 
|---|
|  |  |  | having openCount < #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="openCount != null and openCount > 0"> | 
|---|
|  |  |  | having openCount < #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|