Database finding data I have a table

  PUR# EID PID  CID         QTY  PTIME     TOTAL_PRICE
---------- --- -----       ---- --------- -----------
100001 e01 p002 c001          1 12-AUG-17      211.65
100002 e01 p003 c001          1 20-SEP-17       118.4
100003 e02 p004 c002          5 08-OCT-17        4.95
100005 e04 p007 c004          1 15-OCT-17       119.2
100006 e03 p008 c001          1 12-OCT-17       349.3
100007 e03 p006 c003          2 10-SEP-17       35.91
100008 e03 p006 c005          1 16-AUG-17       17.96
100009 e03 p001 c007          1 12-OCT-17        8.99
100010 e04 p002 c006          1 19-SEP-17      211.65
100011 e02 p004 c006         10 16-OCT-17         9.9
100012 e02 p008 c003          2 18-SEP-17       698.6


I want to find

its pid and cid as well as the number of different customers (header: “number of customers”) who have purchased it in October 2017. If a product has not been purchased by anyone in October 2017, number 0 should be shown. Use column format to change the header to “number of customers”.

P.S: It is not a homework and I am working on a project so finding it difficult
I think you want something like this,

SELECT pid, count(DISTINCT cid) AS "number_of_customers" 
FROM table
WHERE PTIME &gt;= DATE '2017-10-01'
  AND PTIME &lt; DATE '2017-11-01'
GROUP BY pid
HAVING count(DISTINCT cid) &gt; 0;