我有这个用于计算组件的 SQL 查询:
SELECT COUNT(CS.COMPONENTTYPEID) AS CNT
FROM COMPONENTTYPE CT LEFT
OUTER JOIN COMPONENTSTATS CS ON CS.COMPONENTTYPEID = CT.COMPONENTTYPEID
WHERE CT.COMPONENTTYPEID IN (?, ?)
GROUP BY CT.NAME,
CT.COMPONENTTYPEID
ORDER BY CT.COMPONENTTYPEID
我想选择所有具有status = 'Active'
. 我必须插入它的正确位置在哪里?也许是这样:
SELECT COUNT(CS.COMPONENTTYPEID) AS CNT
FROM COMPONENTTYPE CT LEFT
OUTER JOIN COMPONENTSTATS CS ON CS.COMPONENTTYPEID = CT.COMPONENTTYPEID
WHERE CT.COMPONENTTYPEID IN (?, ?) WHERE STATUS = 'Active'
GROUP BY CT.NAME,
CT.COMPONENTTYPEID
ORDER BY CT.COMPONENTTYPEID