未知的列sql查询(解决)

时间:2016-01-12 03:16:53

标签: mysql

我有表absen with clause join,where和group 我有这个查询

SELECT count( tgl ) AS total, 
       absen.id, pegawai.nama, pegawai.bagian, 
       pegawai.bagian, pegawai.tglmasuk, gaji.jenis_gaji, 
       gaji.jumlah, gajiharian.id_gajiharian, 
       gajiharian.status, gajiharian.tgldigaji,
    CASE WHEN (weekday( tgl ) <=3)
         THEN date( tgl + INTERVAL( 3 - weekday( tgl ) ) DAY )
         ELSE date( tgl + INTERVAL( 3 +7 - weekday( tgl ) ) DAY )
    END AS tglitung
FROM absen
   JOIN pegawai ON pegawai.id = absen.id
   JOIN gaji ON gaji.id = pegawai.id
   LEFT JOIN gajiharian ON gajiharian.id = absen.id
WHERE absen.status = 'm'
  AND absen.id = '15'
  AND tglitung='2016-01-14'
GROUP BY absen.id, tglitung

并导致

  

#1054 - 未知专栏&#39; tglitung&#39;在&#39; where子句&#39;

我该如何解决? 我希望&#39; as tglitung&#39;可以检测为列。

0 个答案:

没有答案