Question: title：Ask the user to enter a string of integers and any number of spaces, and finally sum the numbers：

```
#include<stdio.h>
int main()
{
    int sum=0,ch;
    printf ("Please enter an integer of any length and the number of spaces：");  
    scanf ("%d",&ch); 

    while(ch!='13')
    {
        if(ch!='32') sum=sum+ch;
    }
    printf ("sum=%d\n",sum);

    return 0;
}   

```

When I compile and run according to the following code, I can only input, but cannot calculate the sum of the final sum.

Answer: 
I added a with clause to generate last 31 days, then I left joined with your base table like below.

```sql
with last_31_days as (
select trunc(sysdate) - 32 + level dt from dual connect by trunc(sysdate) - 32 + level < trunc(sysdate)
)
SELECT  
nvl(COUNT(t.ID), 0) AS FREQ,
TO_CHAR(
        nvl(TRUNC(t.CREATED_AT), a.dt)
    ,'DD-MON') DATES
FROM last_31_days a 
    LEFT JOIN TICKETS t 
        ON TRUNC(t.CREATED_AT) = a.dt 
GROUP BY nvl(TRUNC(t.CREATED_AT), a.dt)
ORDER BY 2 ASC
;

```
@Littlefoot answer is perfect. but here is a cheeky way to get the similar table with format match OP output. using a simple cte for this.

```
   WITH cte AS (
     SELECT To_Char(Trunc(SYSDATE - ROWNUM),'DD-MON') dtcol
       FROM DUAL 
    CONNECT BY ROWNUM < 366
    )
    SELECT * FROM cte

```

here is [db<>fiddle](https://dbfiddle.uk/?rdbms=oracle_18&fiddle=7369d7c6fe09b170efa66dd2cc61b7e8)

and then you can simply join this cte to fill up empty date. as the origin output column `date` looks like a string column.  

`connect by` is for oracle only. but I think you can still use recursive cte to get similar result in other DBMS support recursive cte.