为什么mysql查询返回零值?

时间:2019-03-15 09:04:37

标签: php mysql

这是我的查询

    if let viewController = UIStoryboard(name: "yourStoryboardID", bundle: nil).instantiateVC(withIdentifier: "yourControllerID") {
        // Use viewController here
        viewController.view.tag = 0; // for example
    }

请参见:

SELECT c.categoryName,
        note1.*,
        ((SELECT SUM(noteAmount)
          FROM notes
          WHERE DATE_FORMAT(noteDate, '%d-%m-%Y') = DATE_FORMAT(note1.noteDate, '%d-%m-%Y') AND noteType = 'in')
        -
        (SELECT SUM(noteAmount)
         FROM notes
         WHERE DATE_FORMAT(noteDate, '%d-%m-%Y') = DATE_FORMAT(note1.noteDate, '%d-%m-%Y') AND noteType = 'out')) as trxCount
       FROM notes AS note1 
       JOIN
         (SELECT noteDate
          FROM notes

          GROUP BY noteDate
          HAVING COUNT(noteDate) > 0)
        AS note2
          ON note1.noteDate = note2.noteDate
        JOIN category c
          ON c.categoryID = note1.categoryID
        ORDER BY note1.noteDate ASC


假设某天是否只有一个收入数据(入)(没有支出数据)。例如in = 15,out =0。在查询中,我输入[in-out](15-0),但是为什么我得到0而不是15?

0 个答案:

没有答案