COUNT(DISTINCT invoiceType1)` AS `#invoices2`,
COUNT(DISTINCT invoiceType2)` AS `#invoices2`,
有没有办法将这两个计数加在一起?虽然它们都是DISTINCT
但我不确定它是否会表现正常。
谢谢。
答案 0 :(得分:0)
试试这个,只需使用'+'运算符
添加这两个计数SELECT
COUNT(DISTINCT invoiceType1) AS #invoices1,
COUNT(DISTINCT invoiceType2) AS #invoices2,
COUNT(DISTINCT invoiceType1) + COUNT(DISTINCT invoiceType2) AS #totalinvoicescount
FROM tablename