Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ GaussDB(DWS)/ Best Practices/ Data Analytics/ Using GaussDB(DWS) to Analyze the Operational Status of a Retail Department Store

Using GaussDB(DWS) to Analyze the Operational Status of a Retail Department Store

Updated on 2024-10-29 GMT+08:00

Background

In this practice, the daily business data of each retail store is loaded from OBS to the corresponding table in the data warehouse cluster for summarizing and querying KPIs. This data includes store turnover, customer flow, monthly sales ranking, monthly customer flow conversion rate, monthly price-rent ratio, and sales per unit area. This example demonstrates the multidimensional query and analysis of GaussDB(DWS) in the retail scenario.

NOTE:

The sample data has been uploaded to the retail-data folder in an OBS bucket, and all HUAWEI CLOUD accounts have been granted the read-only permission to access the OBS bucket.

General Procedure

This practice takes about 60 minutes. The process is as follows:

  1. Preparations
  2. Step 1: Importing Sample Data from the Retail Department Store
  3. Step 2: Performing Operations Status Analysis

Supported Regions

Table 1 describes the regions where OBS data has been uploaded.

Table 1 Regions and OBS bucket names

Region

OBS Bucket

CN North-Beijing1

dws-demo-cn-north-1

CN North-Beijing2

dws-demo-cn-north-2

CN North-Beijing4

dws-demo-cn-north-4

CN North-Ulanqab1

dws-demo-cn-north-9

CN East-Shanghai1

dws-demo-cn-east-3

CN East-Shanghai2

dws-demo-cn-east-2

CN South-Guangzhou

dws-demo-cn-south-1

CN South-Guangzhou-InvitationOnly

dws-demo-cn-south-4

CN-Hong Kong

dws-demo-ap-southeast-1

AP-Singapore

dws-demo-ap-southeast-3

AP-Bangkok

dws-demo-ap-southeast-2

LA-Santiago

dws-demo-la-south-2

AF-Johannesburg

dws-demo-af-south-1

LA-Mexico City1

dws-demo-na-mexico-1

LA-Mexico City2

dws-demo-la-north-2

RU-Moscow2

dws-demo-ru-northwest-2

LA-Sao Paulo1

dws-demo-sa-brazil-1

Preparations

Step 1: Importing Sample Data from the Retail Department Store

After connecting to the cluster using the SQL client tool, perform the following operations in the SQL client tool to import the sample data from retail department stores and perform queries.

  1. Execute the following statement to create the retail database:

    1
    CREATE DATABASE retail encoding 'utf8' template template0; 
    

  2. Perform the following steps to switch to the new database:

    1. In the Object Browser window of the Data Studio client, right-click the database connection and choose Refresh from the shortcut menu. Then, the new database is displayed.
    2. Right-click the name of the new database retail and choose Connect to DB from the shortcut menu.
    3. Right-click the name of the new database retail and choose Open Terminal from the shortcut menu. The SQL command window for connecting to the specified database is displayed. Perform the following steps in the window.

  3. Create a database table.

    The sample data consists of 10 database tables whose associations are shown in Figure 1.

    Figure 1 Sample data tables of retail department stores
    Copy and execute the following statements to switch to create a database table of retail department store information.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    CREATE SCHEMA retail_data;
    SET current_schema='retail_data';
    
    DROP TABLE IF EXISTS STORE;
    CREATE TABLE STORE (
            ID INT, 
            STORECODE VARCHAR(10), 
            STORENAME VARCHAR(100), 
            FIRMID INT, 
            FLOOR INT, 
            BRANDID INT, 
            RENTAMOUNT NUMERIC(18,2), 
            RENTAREA NUMERIC(18,2)
    ) 
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS POS;
    CREATE TABLE POS(
            ID INT, 
            POSCODE VARCHAR(20), 
            STATUS INT, 
            MODIFICATIONDATE DATE
    )
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS BRAND;
    CREATE TABLE BRAND (
            ID INT, 
            BRANDCODE VARCHAR(10), 
            BRANDNAME VARCHAR(100), 
            SECTORID INT
    )
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS SECTOR;
    CREATE TABLE SECTOR(
            ID INT, 
            SECTORCODE VARCHAR(10), 
            SECTORNAME VARCHAR(20), 
            CATEGORYID INT
    )
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS CATEGORY;
    CREATE TABLE CATEGORY(
            ID INT, 
            CODE VARCHAR(10), 
            NAME VARCHAR(20)
    )
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS FIRM;
    CREATE TABLE FIRM(
            ID INT, 
            CODE VARCHAR(4), 
            NAME VARCHAR(40), 
            CITYID INT, 
            CITYNAME VARCHAR(10),
            CITYCODE VARCHAR(20)
    )
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS DATE;
    CREATE TABLE DATE(
            ID INT, 
            DATEKEY DATE, 
            YEAR INT, 
            MONTH INT, 
            DAY INT, 
            WEEK INT, 
            WEEKDAY INT
    )
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS PAYTYPE;
    CREATE TABLE PAYTYPE(
            ID INT, 
            CODE VARCHAR(10), 
            TYPE VARCHAR(10), 
            SIGNDATE DATE
    )
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY REPLICATION;
    
    DROP TABLE IF EXISTS SALES;
    CREATE TABLE SALES(
             ID INT, 
             POSID INT, 
             STOREID INT, 
             DATEKEY INT, 
             PAYTYPE INT, 
             TOTALAMOUNT NUMERIC(18,2),
             DISCOUNTAMOUNT NUMERIC(18,2), 
             ITEMCOUNT INT, 
             PAIDAMOUNT NUMERIC(18,2)
    ) 
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY HASH(ID);
    
    DROP TABLE IF EXISTS FLOW;
    CREATE TABLE FLOW (
             ID INT, 
             STOREID INT, 
             DATEKEY INT, 
             INFLOWVALUE INT
    ) 
    WITH (ORIENTATION = COLUMN, COMPRESSION=MIDDLE) DISTRIBUTE BY HASH(ID);
    

  4. Create a foreign table, which is used to identify and associate the source data on OBS.

    NOTICE:
    • <obs_bucket_name> indicates the OBS bucket name. Only some regions are supported. For details about the supported regions and OBS bucket names, see Supported Regions. GaussDB(DWS) clusters do not support cross-region access to OBS bucket data.
    • , and replace <Access_Key_Id> and <Secret_Access_Key> with the value obtained in Preparations.
    • Hardcoded or plaintext AK/SK is risky. For security, encrypt your AK/SK and store them in the configuration file or environment variables.
    • If the message "ERROR: schema "xxx" does not exist Position" is displayed when you create a foreign table, the schema does not exist. Perform the previous step to create a schema.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    CREATE SCHEMA retail_obs_data;
    SET current_schema='retail_obs_data';
    DROP FOREIGN table if exists SALES_OBS;
    CREATE FOREIGN TABLE SALES_OBS
    (
            like retail_data.SALES
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/sales',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    DROP FOREIGN table if exists FLOW_OBS;
    CREATE FOREIGN TABLE FLOW_OBS
    (
            like retail_data.flow
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/flow',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    DROP FOREIGN table if exists BRAND_OBS;
    CREATE FOREIGN TABLE BRAND_OBS
    (
            like retail_data.brand
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/brand',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    
    DROP FOREIGN table if exists CATEGORY_OBS;
    CREATE FOREIGN TABLE CATEGORY_OBS
    (
           like retail_data.category
    )
    SERVER gsmpp_server 
    OPTIONS (
           encoding 'utf8',
           location 'obs://<obs_bucket_name>/retail-data/category',
           format 'csv',
           delimiter ',',
           access_key '<Access_Key_Id>',
           secret_access_key '<Secret_Access_Key>',
           chunksize '64',
           IGNORE_EXTRA_DATA 'on',
           header 'on'
    );
    
    DROP FOREIGN table if exists DATE_OBS;
    CREATE FOREIGN TABLE DATE_OBS
    (
            like retail_data.date
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/date',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    DROP FOREIGN table if exists FIRM_OBS;
    CREATE FOREIGN TABLE FIRM_OBS
    (
            like retail_data.firm
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/firm',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    
    DROP FOREIGN table if exists PAYTYPE_OBS;
    CREATE FOREIGN TABLE PAYTYPE_OBS
    (
            like retail_data.paytype
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/paytype',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    
    DROP FOREIGN table if exists POS_OBS;
    CREATE FOREIGN TABLE POS_OBS
    (
            like retail_data.pos
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/pos',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    DROP FOREIGN table if exists SECTOR_OBS;
    CREATE FOREIGN TABLE SECTOR_OBS
    (
            like retail_data.sector
    )
    SERVER gsmpp_server 
    OPTIONS (
            encoding 'utf8',
            location 'obs://<obs_bucket_name>/retail-data/sector',
            format 'csv',
            delimiter ',',
            access_key '<Access_Key_Id>',
            secret_access_key '<Secret_Access_Key>',
            chunksize '64',
            IGNORE_EXTRA_DATA 'on',
            header 'on'
    );
    
    
    DROP FOREIGN table if exists STORE_OBS;
    CREATE FOREIGN TABLE STORE_OBS
    (
             like retail_data.store
    )
    SERVER gsmpp_server 
    OPTIONS (
             encoding 'utf8',
             location 'obs://<obs_bucket_name>/retail-data/store',
             format 'csv',
             delimiter ',',
             access_key '<Access_Key_Id>',
             secret_access_key '<Secret_Access_Key>',
             chunksize '64',
             IGNORE_EXTRA_DATA 'on',
             header 'on'
    );
    

  5. Copy and execute the following statements to import the foreign table data to the cluster:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    INSERT INTO retail_data.store SELECT * FROM retail_obs_data.STORE_OBS;
    INSERT INTO retail_data.sector SELECT * FROM retail_obs_data.SECTOR_OBS;
    INSERT INTO retail_data.paytype SELECT * FROM retail_obs_data.PAYTYPE_OBS;
    INSERT INTO retail_data.firm SELECT * FROM retail_obs_data.FIRM_OBS;
    INSERT INTO retail_data.flow SELECT * FROM retail_obs_data.FLOW_OBS;
    INSERT INTO retail_data.category SELECT * FROM retail_obs_data.CATEGORY_OBS;
    INSERT INTO retail_data.date SELECT * FROM retail_obs_data.DATE_OBS;
    INSERT INTO retail_data.pos SELECT * FROM retail_obs_data.POS_OBS;
    INSERT INTO retail_data.brand SELECT * FROM retail_obs_data.BRAND_OBS;
    INSERT INTO retail_data.sales SELECT * FROM retail_obs_data.SALES_OBS;
    

    It takes some time to import data.

  6. Copy and execute the following statement to create the v_sales_flow_details view:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    SET current_schema='retail_data';
    CREATE VIEW v_sales_flow_details AS 
    SELECT 
    FIRM.ID FIRMID, FIRM.NAME FIRNAME, FIRM. CITYCODE,
    CATEGORY.ID CATEGORYID, CATEGORY.NAME CATEGORYNAME, 
    SECTOR.ID SECTORID, SECTOR.SECTORNAME,
    BRAND.ID BRANDID, BRAND.BRANDNAME,
    STORE.ID STOREID, STORE.STORENAME, STORE.RENTAMOUNT, STORE.RENTAREA,
    DATE.DATEKEY, SALES.TOTALAMOUNT, DISCOUNTAMOUNT, ITEMCOUNT, PAIDAMOUNT, INFLOWVALUE
    FROM SALES
    INNER JOIN STORE ON SALES.STOREID = STORE.ID
    INNER JOIN FIRM ON STORE.FIRMID = FIRM.ID
    INNER JOIN BRAND ON STORE.BRANDID = BRAND.ID
    INNER JOIN SECTOR ON BRAND.SECTORID = SECTOR.ID
    INNER JOIN CATEGORY ON SECTOR.CATEGORYID = CATEGORY.ID
    INNER JOIN DATE ON SALES.DATEKEY = DATE.ID
    INNER JOIN FLOW ON FLOW.DATEKEY = DATE.ID AND FLOW.STOREID = STORE.ID;
    

Step 2: Performing Operations Status Analysis

The following uses standard query of retail information from department stores as an example to demonstrate how to perform basic data query on GaussDB(DWS).

Before querying data, run the Analyze command to generate statistics related to the database table. The statistics data is stored in system table PG_STATISTIC and is useful when you run the planner, which provides you with an efficient query execution plan.

The following are querying examples:

  • Querying the monthly sales revenue of each store

    Copy and execute the following statements to query the total revenue of each store in a certain month:

    1
    2
    3
    4
    5
    6
    7
    8
    SET current_schema='retail_data';
    SELECT DATE_TRUNC('month',datekey) 
    AT TIME ZONE 'UTC' AS __timestamp,
    SUM(paidamount)
    AS sum__paidamount
    FROM v_sales_flow_details
    GROUP BY DATE_TRUNC('month',datekey) AT TIME ZONE 'UTC'
    ORDER BY SUM(paidamount) DESC;
    
  • Querying the sales revenue and price-rent ratio of each store

    Copy and execute the following statement to query the sales revenue and price-rent ratio of each store:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    SET current_schema='retail_data';
    SELECT firname AS firname,
    storename AS storename,
    SUM(paidamount)
    AS sum__paidamount,
    AVG(RENTAMOUNT)/SUM(PAIDAMOUNT)
    AS rentamount_sales_rate
    FROM v_sales_flow_details
    GROUP BY firname, storename
    ORDER BY SUM(paidamount) DESC;
    
  • Analyzing the sales revenue of each city

    Copy and execute the following statement to analyze and query the sales revenue of all provinces:

    1
    2
    3
    4
    5
    6
    7
    SET current_schema='retail_data';
    SELECT citycode AS citycode,
    SUM(paidamount)
    AS sum__paidamount
    FROM v_sales_flow_details
    GROUP BY citycode
    ORDER BY SUM(paidamount) DESC;
    
  • Analyzing and comparing the price-rent ratio and customer flow conversion rate of each store
    1
    2
    3
    4
    5
    6
    7
    8
    9
    SET current_schema='retail_data';
    SELECT brandname AS brandname,
    firname AS firname,
    SUM(PAIDAMOUNT)/AVG(RENTAREA) AS sales_rentarea_rate,
    SUM(ITEMCOUNT)/SUM(INFLOWVALUE) AS poscount_flow_rate,
    AVG(RENTAMOUNT)/SUM(PAIDAMOUNT) AS rentamount_sales_rate
    FROM v_sales_flow_details
    GROUP BY brandname,  firname
    ORDER BY sales_rentarea_rate DESC;
    
  • Analyzing brands in the retail industry
    1
    2
    3
    4
    5
    6
    7
    8
    SET current_schema='retail_data';
    SELECT categoryname AS categoryname,
    brandname AS brandname,
    SUM(paidamount) AS sum__paidamount
    FROM v_sales_flow_details
    GROUP BY categoryname,
    brandname
    ORDER BY sum__paidamount DESC;
    
  • Querying daily sales information of each brand
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    SET current_schema='retail_data';
    SELECT brandname AS brandname,
    DATE_TRUNC('day', datekey) AT TIME ZONE 'UTC' AS __timestamp,
    SUM(paidamount) AS sum__paidamount
    FROM v_sales_flow_details
    WHERE datekey >= '2016-01-01 00:00:00'
    AND datekey <= '2016-01-30 00:00:00'
    GROUP BY brandname,
    DATE_TRUNC('day', datekey) AT TIME ZONE 'UTC'
    ORDER BY sum__paidamount ASC
    LIMIT 50000;
    

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback