我收到错误> 1054-“ where子句”中的未知列“ t.Subject”,请在查询中更正我

时间:2019-05-21 04:04:02

标签: mysql

SELECT c1.Id, c1.Description NAME,
    IFNULL(t2.InProgress, 0) InProgress, IFNULL(t2.Closed, 0) Closed,
    IFNULL(t2.TotalCase, 0) TotalCase,
    TIME_FORMAT(SEC_TO_TIME(IFNULL(t2.tResponseTime, 0)),'%H:%i:%s')
    tResponseTime,
    TIME_FORMAT(SEC_TO_TIME(IFNULL(t2.tResolutionTime, 0)),'%H:%i:%s')
    tResolutionTime FROM 
        (SELECT c1.SiteId, c1.Id,
                CONCAT(CASE WHEN c3.Id IS NOT NULL THEN ' - ' ELSE '' END,
                       CASE WHEN c2.Id IS NOT NULL THEN ' - ' ELSE '' END,
                       c1.Description) Description,
                CONCAT(IF(c3.Id IS NULL, '', LPAD(c3.Id, 10, '0')),
                       IF(c2.Id IS NULL, '', LPAD(c2.Id, 10, '0')),
                       IF(c1.Id IS NULL, '', LPAD(c1.Id, 10, '0'))) CODE
        FROM Category c1
        LEFT JOIN Category c2 ON c1.ParentId=c2.Id
        LEFT JOIN Category c3 ON c2.ParentId=c3.Id
            WHERE c1.SiteId=43 
            AND (c2.SiteId IS NULL OR c2.SiteId=43) 
            AND (c3.SiteId IS NULL OR c3.SiteId=43)
        UNION ALL
            SELECT 43, NULL, 'N/A', '') c1
    LEFT JOIN 
        (SELECT t.CategoryId , 
            IFNULL(SUM(CASE WHEN t.StatusId IN ('TS1', 'TS2', 'TS3', 'TS4', 'TS5', 'TS6') THEN 1 ELSE 0 END), 0)
            InProgress, 
            IFNULL(SUM(CASE WHEN t.StatusId IN ('TS7') THEN 1 ELSE 0 END), 0) Closed, 
            COUNT(*) TotalCase, 
            t.`Subject` AS `Subject`,
            AVG(t.ResponseTime) tResponseTime, 
            AVG(t.ResolutionTime) tResolutionTime 
        FROM Ticket t 
            WHERE t.SiteId=43 #$paramcondition
        GROUP BY t.CategoryId) t2
    ON c1.Id=t2.CategoryId OR (c1.Id IS NULL AND t2.CategoryId IS NULL)
    WHERE c1.SiteId=43 AND t.`Subject` LIKE '%a%' 
    AND c1.Description LIKE '%a%' 
    AND c.Description LIKE '%a%' 
    AND c.`Name` LIKE '%a%' #$statuscondition
ORDER BY c1.Code;
  
    

1054-“ where子句”中的未知列“ t.Subject”     时间:0.001秒

         

1054-“ where子句”中的未知列“ c.Description”     时间:0.001秒

         

1054-“ where子句”中的未知列“ c.Name”     时间:0.001秒

  

0 个答案:

没有答案