官术网_书友最值得收藏!

Loading some sample data

To make this chapter a pleasant experience for you, I have compiled some sample data, which has been taken from the BP energy report: http://www.bp.com/en/global/corporate/energy-economics/statistical-review-of-world-energy.html.

Here is the data structure that will be used:

test=# CREATE TABLE t_oil ( 
region text,
country text,
year int,
production int,
consumption int
);
CREATE TABLE

The test data can be downloaded from our website using curl directly:

test=# COPY t_oil FROM PROGRAM ' curl www.cybertec.at/secret/oil_ext.txt '; 
COPY 644

As in the previous chapter, you can download the file before importing it. On some operating systems, curl is not there by default or has not been installed, so downloading the file before might be an easier option for many people.

There is data for 14 nations between 1965 and 2010, which are in two regions of the world:

test=# SELECT region, avg(production) FROM   t_oil GROUP BY region;
region | avg
---------------+-----------------------
Middle East | 1992.6036866359447005
North America | 4541.3623188405797101
(2 rows)
主站蜘蛛池模板: 灯塔市| 晋州市| 平果县| 陆良县| 武宣县| 永嘉县| 泗阳县| 吉隆县| 广元市| 宜丰县| 偏关县| 宁明县| 万州区| 武汉市| 察哈| 夏邑县| 五家渠市| 筠连县| 加查县| 南汇区| 罗定市| 平利县| 双城市| 马关县| 磴口县| 洛阳市| 成武县| 丰宁| 治多县| 仙居县| 桐柏县| 平定县| 容城县| 凤阳县| 扬州市| 洛南县| 徐闻县| 扬中市| 惠州市| 西贡区| 雷波县|