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

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)
主站蜘蛛池模板: 东城区| 大冶市| 青州市| 灵宝市| 永和县| 韶关市| 长武县| 米林县| 洪洞县| 赣州市| 扬州市| 安义县| 渑池县| 渑池县| 内黄县| 金门县| 合水县| 林芝县| 平原县| 海城市| 淮北市| 建昌县| 都兰县| 茶陵县| 兰溪市| 茌平县| 静宁县| 耒阳市| 三河市| 巨野县| 肃南| 闽侯县| 萨迦县| 苏尼特左旗| 海兴县| 确山县| 高台县| 安达市| 团风县| 汉阴县| 大悟县|