查询结构错误

时间:2017-04-10 14:35:57

标签: mysql sql

我有一些像这样的属性:

enter image description here

我只想从那个属性中获取YEAR。为了您的信息,TanggalMasuk意味着DATE。

我有这样的查询:

select DISTINCT YEAR(TanggalMasuk), 
    (SELECT COUNT(*) AS `Lakilaki` from `kampusmst_orang` 
        LEFT JOIN `akdmst_mahasiswasarjana` on `kampusmst_orang`.`NIMS1Key` = convert(`akdmst_mahasiswasarjana`.`NIM` using utf8) 
        WHERE `JenisKelaminID` = 1 AND `mhsMagister`.YEAR(TanggalMasuk)=`akdmst_mahasiswasarjana`.YEAR(TanggalMasuk)) AS `Lakilaki`,

    (SELECT COUNT(*) AS `Perempuan` from `kampusmst_orang` 
    LEFT JOIN `akdmst_mahasiswasarjana` on `kampusmst_orang`.`NIMS1Key` = convert(`akdmst_mahasiswasarjana`.`NIM` using utf8) 
    WHERE `JenisKelaminID` = 2 AND `mhsMagister`.YEAR(TanggalMasuk)=`akdmst_mahasiswasarjana`.YEAR(TanggalMasuk)) AS `Perempuan`,


    (SELECT COUNT(*) AS `Lainlain` from `kampusmst_orang` 
    LEFT JOIN `akdmst_mahasiswasarjana` on `kampusmst_orang`.`NIMS1Key` = convert(`akdmst_mahasiswasarjana`.`NIM` using utf8) 
    WHERE `JenisKelaminID` = 5 AND `mhsMagister`.YEAR(TanggalMasuk)=`akdmst_mahasiswasarjana`.YEAR(TanggalMasuk)) AS `Lainlain`,

    (SELECT COUNT(*) AS `Total` from `kampusmst_orang` 
    LEFT JOIN `akdmst_mahasiswasarjana` on `kampusmst_orang`.`NIMS1Key` = convert(`akdmst_mahasiswasarjana`.`NIM` using utf8) 
    WHERE `mhsMagister`.YEAR(TanggalMasuk)=`akdmst_mahasiswasarjana`.YEAR(TanggalMasuk)) AS `Total`

    from `akdmst_mahasiswasarjana` AS `mhsMagister` 
    ORDER BY `mhsMagister`.YEAR(TanggalMasuk)

但结果是错误的。这是消息错误:

enter image description here

我该怎么做才能解决这个问题?提前完成了

0 个答案:

没有答案