Home > database >  Packet count (*) to 0 records don't show?
Packet count (*) to 0 records don't show?

Time:09-22

Select count (*), business_id from tb_smp_sms_history_201409 t where latn_id=919 and business_id (1005001100002100003) in group by business_id

CodePudding user response:

Business_id (1005001100002100003) this is a condition in
Find need through the summary record, then I have nothing to do with this condition the
Data in the table there is no record of 1005003 group of natural won't appear in the results

CodePudding user response:

So that how to put the empty record displayed such

0, 1005003

CodePudding user response:

I put the count (*) to NVL (count (*), 0) or not so 3 records

CodePudding user response:

 

- this will use outside link way, the machine didn't know that you want to display the three numerical conditions,
With mt as (
Select the from 1005001 c dual
Union all
Select the from 1005002 dual
Union all
Select the from 1005003 dual
)
Select mt. C, count (*)
The from mt left join tb_smp_sms_history_201409 t on business_id=mt c
Where latn_id=919
Group by mt. C

CodePudding user response:

Union all...

CodePudding user response:

Do you have any similar code tables: business_id
With business_id coding table and your query left connection:

The select a. usiness_id NVL (b.b 1, 0) combined
From the chart a left join
(select count (*), b1, business_id from tb_smp_sms_history_201409 t where latn_id=919 and business_id (1005001100002100003) in group by business_id) b
On a. usiness_id=b.b usiness_id
Group by a. usiness_id
;

CodePudding user response:

The
refer to the original poster u013992697 response:
select count (*), business_id from tb_smp_sms_history_201409 t where latn_id=919 and business_id (1005001100002100003) in group by business_id


Since there are contradictions, is group and count only recorded groupby so, count (*) for at least 1 ah, how could have 0 record

CodePudding user response:

The
reference 7 floor huangdh12 response:
Quote: refer to the original poster u013992697 response:

Select count (*), business_id from tb_smp_sms_history_201409 t where latn_id=919 and business_id (1005001100002100003) in group by business_id


Since there are contradictions, is group and count only recorded groupby so, count (*) for at least 1 ah, how could have 0 record

Upstairs said good, since want to group by so no when I was in the group will not be counted,

CodePudding user response:

6th floor is correct

CodePudding user response:

There should be a design table business_id this field is the main table, first select the main table and then leap join tb_smp_sms_history_201409 group by business_id

CodePudding user response:

reference 1st floor bw555 response:
business_id (1005001100002100003) this is a condition in
Find need through the summary record, then I have nothing to do with this condition the
Data in the table there is no record of 1005003 group of natural won't appear in the results


Why struggle, copying out execl plus 1005003 to 0,

CodePudding user response:

Your (latn_id=919 and business_id=1005003)=false!
Don't want to show it
 
Select a. usiness_id nvi (biggest nt, 0) as CNT
The from (select business_id
The from tb_smp_sms_history_201409 t
Where business_id in (1005001, 1005002, 1005003). A,
(select count (*) as CNT, business_id
The from tb_smp_sms_history_201409 t
Where latn_id=919
And business_id in (1005001, 1005002, 1005003)
Group by business_id) b
Where a. usiness_id=b.b usiness_id

But in fact from a statistical standpoint, this does not exist the value of no significance

CodePudding user response:

The
reference 7 floor huangdh12 response:
Quote: refer to the original poster u013992697 response:

Select count (*), business_id from tb_smp_sms_history_201409 t where latn_id=919 and business_id (1005001100002100003) in group by business_id


Since there are contradictions, is group and count only recorded groupby so, count (*) for at least 1 ah, how could have 0 record


Upstairs said is right,

CodePudding user response:

The union all said above method is good,
This put the union all surface, or we the default 0 and the count ()/group union all sum again together, the result of the

 
Select sum (CNT) as CNT, business_id
The from (
Select 0 as CNT, 1005001 as business_id from dual
Union all
Select 0 as CNT, 1005002 as business_id from dual
Union all
Select 0 as CNT, 1005003 as business_id from dual
Union all
Select 1 as CNT, business_id
The from tb_smp_sms_history_201409 t
Where latn_id=919 and business_id in (1005001100002100003)
) a
Group by business_id

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related