나는 고객이 한 전화의 결과와 고객을 위해 작성한 제안 등을 반환하는 쿼리를 가지고있다. 그 특정 날짜에 대한 그룹화는 ...SQL : concat()에 의한 그룹 사용
는하지만 지금 내가 lead_id
과 cuncat(lead_id,timecreatredFormat)
에 의해 그룹화 시도 고객의 수는 여전히 데이터 불일치 아래
가 찾으려는 것은 내가 미리
에select
sum(t.enquiry_cnt),
sum(t.suggested_cnt),
sum(t.tot_cnt)
from
(select
case
when source = 1 then 1
else 0
end enquiry_cnt,
case
when source = 6 then 1
else 0
end suggested_cnt,
case
when (source = 1 || source = 6) then 1
else 0
end tot_cnt,
date_format(timecreated, '%d-%b-%Y') created_time,
lead_id,timecreated
from
mg_lead_suggested_listing group by concat(created_time,lead_id) ) t
group by t.created_time
order by t.timecreated desc
limit 10;
감사를 시도 쿼리입니다
** group을 lead_id, DATE (timecreated) **로 사용할 수 없습니까? – StanislavL
쿼리 및 필요한 출력 형식에 사용되는 테이블의 구조를 게시 할 수 있다면 도움이됩니다. concat (created_time, lead_id)로 그룹을 제거하고 select에 COUNT (t.lead_id)를 추가하십시오. 그것은 작동 할 수 있습니다 – Sandeep
당신의 상환에 감사합니다 @ StanislavL : 그것은 작동하지 않지만 어떤 경우에는 작동하지 않는 경우도 있습니다. @Sandeep : 테이블의 게시 구조를 시도합니다 참고 COUNT (t.lead_id) in select 작동 becz 내가 특정 조건에 의해 계산을 해야하는 경우 –