Search code examples
oracle-databaseoracle11g

How to visualize the result to show only 3 rows


I`m trying to show in my table only 3 rows and they need to contain from Calendar_month_number numbers 4,5,6 https://i.sstatic.net/SzYgY.png

any suggestions

    select s.PROD_ID,t.DAY_NUMBER_IN_MONTH,t.CALENDAR_MONTH_NUMBER,sum(s.AMOUNT_SOLD)
from CUSTOMERS c join SALES s
on c.CUST_ID=s.CUST_ID
join TIMES t
on s.TIME_ID=t.TIME_ID
where s.PROD_ID = 5
and t.TIME_ID BETWEEN '01-APR-00'and '01-JUL-00'
group by s.PROD_ID,t.DAY_NUMBER_IN_MONTH,t.CALENDAR_MONTH_NUMBER
having sum(s.AMOUNT_SOLD) > 0;

Solution

  • Well, apparently this would be

    select t.CALENDAR_MONTH_NUMBER,sum(s.AMOUNT_SOLD)
      from CUSTOMERS c
      INNER JOIN SALES s
        on c.CUST_ID=s.CUST_ID
      INNER JOIN TIMES t
        on s.TIME_ID=t.TIME_ID
      where s.PROD_ID = 5 and
            t.TIME_ID BETWEEN '01-APR-00'and '01-JUL-00'
      group by t.CALENDAR_MONTH_NUMBER
      having sum(s.AMOUNT_SOLD) > 0;