Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Reduce data rows

I've a table of purchased items stored in the Data Warehouse. The table has almost 20 million records. The table maintains daily transactions and hence the number if rows is huge. I want to find a w...
  • marcelsmaglhaes's avatar
    marcelsmaglhaes
    3 years ago

    Hey Anonymous !

    You can write your SQL like below:

    SELECT 

     EXTRACT(YEAR FROM YOUR_DATE_FIELD) AS year,
      EXTRACT(MONTH FROM  YOUR_DATE_FIELD) AS month,
        CUSTOMER, GROUP, MATERIAL,
      SUM(CUSTOMER_QUANTITY) AS CUSTOMER_QUANTITY
    FROM YOUR_TABLE
    GROUP BY
      EXTRACT(YEAR FROM YOUR_DATE_FIELD),
      EXTRACT(MONTH FROM YOUR_DATE_FIELD),
        CUSTOMER,
       MATERIAL,
       GROUP
     
    If this helps, please mark this question as solved to help people find quickly in our community!