Home > database >  The query of the total number of SQL
The query of the total number of SQL

Time:01-17

Consult a problem bosses, I now have a power outage t_pw_tdxx information table, a unit of information table t_gzdw, power information query contained in the required fields dev_power_cut power line equipment power line equipment into the main line, regional power, with power outages, changeable unit of information in the table contains the query name field name unit required, need according to the name of the group now query line outage number, number of regional power outages, with variable power quantity and main power failure, regional power cuts, with the total number of the outage and changeable now that I've written the grouping query line outage number, number of regional power cuts, with variable number of power outages, statement as follows, could you tell me the main line power, regional power outages, with variable power grouping the total number of the query SQL to how to write?
Select a t1. *, (select count (*) from t_pw_tdxx where instr (porgname, t1. NAME)!='all'=0 and dev_power_cut QXTD,
(select count (*) from t_pw_tdxx where instr (porgname, t1. NAME)!='regional'=0 and dev_power_cut) ZXTD,
(select count (*) from t_pw_tdxx where instr (porgname, t1. NAME)!=0 and dev_power_cut='with' changeable ") PBTD from T_GZDW t1




  • Related