0

I am trying to write a report which has multiple counts:

SELECT 
C.REGION,
COUNT (C.id) AS 'No of customers',
COUNT (C.id) AS 'No of new customers', 
COUNT (C.id) As 'No of waiting customers',
COUNT (C.id) As 'Total No of help available'

FROM CUSTOMER C
INNER JOIN CUSTOMERPARAMETER CP ON C.ID=CP.ID 
WHERE (C.DATEOFBIRTH IS NULL)
GROUP BY C.REGION

The problem is each of my counts are populated by different queries. What is the best way to create a multiple query report?

It doesnt allow me to write a select statement for each count... I need to write a DIFFERENT query for each count. But it wont let me.

4

1 回答 1

0

如果没有有关表架构的更多信息,我可以为您指出正确的方向:

SELECT C.REGION,
    (SELECT COUNT(*) FROM <...>) AS 'No of customers',
    (SELECT COUNT(*) FROM <...>) AS 'No of new customers', 
    (SELECT COUNT(*) FROM <...>) As 'No of waiting customers',
    (SELECT COUNT(*) FROM <...>) As 'Total No of help available'
FROM CUSTOMER C ....

替换<...>为每列所需的条件,您应该进行设置。

请参阅此类子查询的参考:用于代替表达式的子查询

希望这可以帮助

于 2013-08-02T22:20:29.473 回答