Let's say there are four records in ks_temp
insert into ks_temp values ( 10, 1000)
insert into ks_temp values ( 20, 2000)
insert into ks_temp values ( 20, 3000)
insert into ks_temp values ( 20, 4000)
If customer_id in where clause is 10, then I want 1 , 1000 as output.
( here 1 is the count of orders for the customer, 1000 is the order_id
)
If customer_id in where clause is 20, then I want 3 , -99999 as
output. ( here 3 is the count of orders for the customer, -99999 is
any random number )
If customer_id in where clause is 50, then I want 0 , 0 as output. (
here 0 is the count of orders for the customer, 0 is indicating 0
orders )
I am not sure if union can be used as suggested because it would
return incorrect count.