select
COUNT(pd.property_id) AS `Beginning Total File Count`,
COUNT(pd.recv_dt) as `average days in inventory`,
AVG(pd.status = 'P') as `average days in pre-marketing`,
AVG(pd.status NOT IN('I','C')) as `average days onMarket`,
AVG(pd.status ='U') as `average days UnderContract`,
SUM(pd.status = 'O') as `Total FilesOccupied Status`,
SUM(pd.status = 'O') / COUNT(pd.property_id) as `percentage of Occupied /
total file count`
from resnet.property_Details pd
我想要
答案 0 :(得分:1)
好的,这是一个非常疯狂的猜测,你是在这个请求之后:
select
COUNT(distinct pd.property_id) AS `Beginning Total File Count`,
COUNT(pd.recv_dt) as `average days in inventory`,
AVG(IF(pd.status = 'P', 1,0)) as `average days in pre-marketing`,
AVG(IF(pd.status NOT IN('I','C'), 1,0)) as `average days onMarket`,
AVG(IF(pd.status ='U', 1,0)) as `average days UnderContract`,
SUM(IF(pd.status = 'O', 1,0)) as `Total FilesOccupied Status`,
SUM(IF(pd.status = 'O', 1,0)) / COUNT(pd.property_id) as `percentage of Occupied /
total file count`
from resnet.property_Details pd
但是如果你没有使用AVG()
语句,那么使用group by
似乎很奇怪...(它只是一个条件总和,或者你需要按某种方式分组)