-
Notifications
You must be signed in to change notification settings - Fork 0
/
qview_planetary_statistics_plain.sql
16 lines (16 loc) · 1.15 KB
/
qview_planetary_statistics_plain.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
CREATE OR REPLACE ALGORITHM = UNDEFINED VIEW qview_planetary_statistics_plain AS
SELECT
dp.d AS date,
dp.m AS main_pilot_name,
(SELECT quantity FROM qview_planetary_statistics WHERE tier_id=1 AND dp.d=date AND dp.p=main_pilot_id) p1q,
(SELECT quantity FROM qview_planetary_statistics WHERE tier_id=2 AND dp.d=date AND dp.p=main_pilot_id) p2q,
(SELECT quantity FROM qview_planetary_statistics WHERE tier_id=3 AND dp.d=date AND dp.p=main_pilot_id) p3q,
(SELECT quantity FROM qview_planetary_statistics WHERE tier_id=4 AND dp.d=date AND dp.p=main_pilot_id) p4q,
(SELECT volume FROM qview_planetary_statistics WHERE tier_id=1 AND dp.d=date AND dp.p=main_pilot_id) p1v,
(SELECT volume FROM qview_planetary_statistics WHERE tier_id=2 AND dp.d=date AND dp.p=main_pilot_id) p2v,
(SELECT volume FROM qview_planetary_statistics WHERE tier_id=3 AND dp.d=date AND dp.p=main_pilot_id) p3v,
(SELECT volume FROM qview_planetary_statistics WHERE tier_id=4 AND dp.d=date AND dp.p=main_pilot_id) p4v
FROM
(SELECT DISTINCT date AS d, main_pilot_id AS p, main_pilot_name AS m FROM qview_planetary_statistics) dp
-- ORDER BY 1 DESC
;