ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
ddemo |
(29 rows)
kid_friendly_dvds_xt_err
list_c
male_first_names_xt_err
order_lineitems
order_lineitems_stage
orders
payment_methods
products_dim
products_xt_err
raw_zip_city_state_xt_err
state_sales_taxes_xt_err
streets
streets_xt_err
surnames_xt_err
websites_xt_err
weekly_sales
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
table
table
table
table
table
table
table
table
table
table
table
table
table
table
table
table
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
gpadmin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
heap
heap
heap
append
heap
append
append
append
heap
heap
heap
append
heap
heap
heap
heap
only
only
only
only
only
Type
|
Modifiers
| Storage | Description
-------------+------------------------+--------------------------------------------------------------------+----------+------------customer_id | integer
| not null default nextval('customers_dim_
customer_id_seq'::regclass) | plain
|
first_name | character varying(100) | not null
| extended |
last_name | character varying(200) | not null
| extended |
gender
| character(1)
|
| extended |
Compression Type: quicklz
Compression Level: 1
Block Size: 32768
Checksum: f
Has OIDs: no
Options: appendonly=true, compresstype=quicklz
Distributed by: (customer_id)
training1=# SELECT gender,count(*) FROM customers_dim GROUP BY gender;
gender | count
--------+-------M
| 500959
F
| 499041
(2 rows)
training1=#
training1=#
training1-#
training1-#
training1-#
training1-#
training1-#
training1-#
training1-#
SELECT
c.gender
, AVG(o.item_price) AS avg_price
FROM
ddemo.order_lineitems AS o
JOIN
ddemo.customers_dim AS c
ON o.customer_id = c.customer_id
[gpadmin@pod4-be LAB01]$
[gpadmin@pod4-be LAB01]$ psql
psql (8.2.15)
Type "help" for help.
template1=# \c training2
You are now connected to database "training2" as user "gpadmin".
training2=# \dt
List of relations
Schema | Name | Type | Owner | Storage
--------+---------+-------+---------+--------public | fips
| table | gpadmin | heap
public | housing | table | gpadmin | heap
public | persons | table | gpadmin | heap
public | zeta
| table | gpadmin | heap
(4 rows)
training2=#
training2=# \dn
List of schemas
Name
| Owner
--------------------+--------gp_toolkit
| gpadmin
information_schema | gpadmin
madlib
| gpadmin
myschema
| gpadmin
pg_aoseg
| gpadmin
pg_bitmapindex
| gpadmin
pg_catalog
| gpadmin
pg_toast
| gpadmin
public
| gpadmin
(9 rows)
training2=#
training2=# SELECT
training2-# SUM(c) AS total_records
training2-# , SUM(CASE WHEN c>1 THEN c-1 ELSE 0 END) AS total_dupes
training2-# , COUNT(*) AS total_uniques
training2-# FROM (
training2(# SELECT
training2(# COUNT(*) AS c
training2(# FROM
training2(# housing
training2(# GROUP BY
training2(# serialno
training2(# , state
training2(# ) AS dupes
training2-# ;
total_records | total_dupes | total_uniques
---------------+-------------+--------------12515394 |
6257697 |
6257697
(1 row)
training2=# \dt
List of relations
Schema | Name | Type | Owner | Storage
--------+---------+-------+---------+--------public | fips
| table | gpadmin | heap
public | housing | table | gpadmin | heap
public | persons | table | gpadmin | heap
public | zeta
| table | gpadmin | heap
(4 rows)
training2=# DROP TABLE IF EXISTS housing_nodupes;
NOTICE: table "housing_nodupes" does not exist, skipping
DROP TABLE
training2=#
training2-#
training2-#
training2-#
training2-#
training2-#
training2-#
SELECT 6257697
training2=#
training2=#
training2=# SELECT
training2-# SUM(c) AS total_records
training2-# , SUM(CASE WHEN c>1 THEN c-1 ELSE 0 END) AS total_dupes
training2-# , COUNT(*) AS total_uniques
training2-# FROM (
training2(# SELECT
training2(# COUNT(*) AS c
training2(# FROM
training2(# housing_nodupes
training2(# GROUP BY
training2(# serialno
training2(# , state
training2(# ) AS dupes
training2-# ;
total_records | total_dupes | total_uniques
---------------+-------------+--------------6257697 |
0 |
6257697
(1 row)
training2=# SELECT
training2-# corr(hinc, rooms)
training2-# FROM
training2-# housing_nodupes
training2-# WHERE
training2-# state = 25
training2-# ;
corr
------------------0.374485423827578
(1 row)
training2=#
training2=# SELECT * FROM fips WHERE code = 25;
code | name
------+-----25 | MA
(1 row)
training2=#
training2=#
training2=# SELECT
training2-# regr_r2(hinc, rooms)
training2-# FROM
training2-# housing_nodupes
training2-# WHERE
training2-# state = 25
training2-# ;
regr_r2
------------------0.140239332659321
(1 row)
training2=#
training2-#
training2-#
training2-#
training2-#
training2-#
training2-#
training2-#
training2-#
training2-#
training2=#
SELECT
serialno
, hinc
, rooms
FROM
housing_nodupes
WHERE
hinc > 0
AND state = 25
;
\a
\o lab1_01.txt
SELECT
serialno
, hinc
, rooms
FROM
housing_nodupes
WHERE
hinc > 0
AND state = 25
;