SELECT pj.type AS type, count( pj.id ) AS project_count, count( evt.id ) AS alarm_count, ( SELECT count(id) from t_device where type=1) as camera_count, ( SELECT count(id) from t_device where type=2) as ai_box_count, ( SELECT count(id) from t_device where type=3) as radar_count, ( SELECT count(id) from t_device where type=4) as sensor_count, ( SELECT count(evt.id) FROM t_probably where project=pj.id AND status <> 1 and status is not null ORDER BY alarm_time DESC LIMIT 1 ) AS dissipate_event FROM t_project AS pj LEFT JOIN t_device AS dev ON pj.id = dev.project LEFT JOIN t_probably AS evt ON pj.id = evt.project LEFT JOIN t_organize AS org ON pj.organize = org.id ORDER BY pj.type DESC 在这段sql中,为什么project_count的数据和表里数据数量不一致
时间: 2023-06-13 10:08:34 浏览: 83
可能是因为在 JOIN 表时,有些项目(t_project)没有对应的设备(t_device)或报警(t_probably),这些项目在统计 project_count 时会被算作 0,导致最终的 project_count 数量和表中的数据数量不一致。另外,如果在 t_project 表中有重复的 id,也会导致最终的统计结果与表中的数据数量不一致。
相关问题
“self.m_button1.Bind(wx.EVT_BUTTON, MyDialog11(None).OnClick) self.m_button2.Bind(wx.EVT_BUTTON, MyDialog12(None).OnClick) self.m_button3.Bind(wx.EVT_BUTTON, MyDialog13(None).OnClick) self.m_button4.Bind(wx.EVT_BUTTON, MyDialog21(None).OnClick) self.m_button5.Bind(wx.EVT_BUTTON, MyDialog22(None).OnClick) self.m_button6.Bind(wx.EVT_BUTTON, MyDialog23(None).OnClick) self.m_button7.Bind(wx.EVT_BUTTON, MyDialog31(None).OnClick) self.m_button8.Bind(wx.EVT_BUTTON, MyDialog32(None).OnClick) self.m_button9.Bind(wx.EVT_BUTTON, MyDialog33(None).OnClick) self.m_button10.Bind(wx.EVT_BUTTON, MyDialog41(None).OnClick) self.m_button11.Bind(wx.EVT_BUTTON, MyDialog42(None).OnClick) self.m_button12.Bind(wx.EVT_BUTTON, MyDialog43(None).OnClick) self.m_button13.Bind(wx.EVT_BUTTON, MyDialog44(None).OnClick) self.m_button14.Bind(wx.EVT_BUTTON, MyDialog51(None).OnClick) self.m_button15.Bind(wx.EVT_BUTTON, MyDialog52(None).OnClick) self.m_button16.Bind(wx.EVT_BUTTON, MyDialog53(None).OnClick)”逐行翻译
这段代码是用来绑定多个按钮的事件处理函数的。具体来说,代码中的每一行都使用了Bind方法将一个按钮的事件(wx.EVT_BUTTON)与一个对应的事件处理函数(MyDialogXX(None).OnClick)进行绑定。其中,MyDialogXX(None)是一个对话框类的实例化对象,XX代表对话框的编号,用于区分不同的对话框;OnClick是对话框类中的一个方法,用于响应按钮的点击事件。整个代码的作用是为多个按钮分别绑定对应的事件处理函数,以实现不同的功能。
void sl_notify_gap_evt_to_porting_layer(sl_bt_msg_t *evt) { sl_status_t sc; bd_addr address; uint8_t address_type; struct ble_gap_event event; memset(&event, 0, sizeof(event)); switch (SL_BT_MSG_ID(evt->header)) { // ------------------------------- // This event is generated when an advertisement packet or a scan response // is received from a responder case sl_bt_evt_scanner_legacy_advertisement_report_id: memset(&event, 0, sizeof(event)); event.type = BLE_GAP_EVENT_DISC; event.disc.event_type = convert_to_nimble_adv_type(evt->data.evt_scanner_legacy_advertisement_report.event_flags); event.disc.length_data = evt->data.evt_scanner_legacy_advertisement_report.data.len; event.disc.data = evt->data.evt_scanner_legacy_advertisement_report.data.data; event.disc.addr.type = evt->data.evt_scanner_legacy_advertisement_report.address_type; memcpy(event.disc.addr.val, evt->data.evt_scanner_legacy_advertisement_report.address.addr, 6); event.disc.rssi = evt->data.evt_scanner_legacy_advertisement_report.rssi; notify_ble_event_to_listeners(&event); break; // ------------------------------- // This event indicates that a new connection was opened. case sl_bt_evt_connection_opened_id: event.type = BLE_GAP_EVENT_CONNECT; event.connect.conn_handle = evt->data.evt_connection_opened.connection; app_log_info("BLE connected, conn_id:%d\n", event.connect.conn_handle); notify_ble_event_to_listeners(&event); break; // ------------------------------- // This event indicates that a connection was closed. case sl_bt_evt_connection_closed_id: event.type = BLE_GAP_EVENT_DISCONNECT; event.disconnect.conn.conn_handle = evt->data.evt_connection_closed.connection; event.disconnect.reason = evt->data.evt_connection_closed.reason; app_log_info("BLE disconnected, conn_id:%d, reason:0x%02x\n", event.disconnect.conn.conn_handle, event.disconnect.reason); notify_ble_event_to_listeners(&event); break; case sl_bt_evt_gatt_mtu_exchanged_id: event.type = BLE_GAP_EVENT_MTU; event.mtu.conn_handle = evt->data.evt_gatt_mtu_exchanged.connection; event.mtu.value = evt->data.evt_gatt_mtu_exchanged.mtu; app_log_info("exchange mtu req: %d\n", event.mtu.value); notify_ble_event_to_listeners(&event); break; default: break; } }
这是一个函数的具体实现,实现了将 GAP 事件通知到 porting layer 的功能。函数接收一个 `sl_bt_msg_t` 类型的指针作为参数,根据不同的 GAP 事件类型,将事件转换成 nimble 的 BLE GAP 事件,然后通知给监听器进行处理。其中,不同的 GAP 事件类型包括扫描响应、连接建立、连接断开、MTU 交换等。通过这个函数,可以将不同的 GAP 事件转换成标准的 BLE GAP 事件,方便上层应用进行处理。具体实现细节可以参考代码注释。
阅读全文