šŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych
Article #195445

Funkcje WINDOW

#195445
From: Roman Tyczka
Date: Mon, 27 Nov 2017 19:05
29 lines
1487 bytes
Witam,

Bawię się z funkcjami WINDOW, znaczy próbuję, pierwszy test i mam pytania.

SELECT A, B, C,
 SUM(C) OVER (),
 SUM(C) OVER (ORDER BY A, B),
 SUM(C) OVER (PARTITION BY A),
 SUM(C) OVER (PARTITION BY A ORDER BY B)
 FROM TEST

i wyniki:

A|  B|   C|  SUM| SUM_1| SUM_2| SUM_3|      
-------------------------------------
1|  1|  30|  141|    30|    60|    30| 
1|  2|  20|  141|    50|    60|    50| 
1|  3|  10|  141|    60|    60|    60| 
2|  1|  25|  141|    85|    40|    25| 
2|  2|  15|  141|   100|    40|    40| 
3|  1|  41|  141|   141|    41|    41| 

kolumna SUM i SUM_2 są jasne. 
Ale jak liczone są wartości w kolumnie SUM_1 i SUM_3?
Wszak ORDER BY wpływa na kolejność, czemu więc sumy są inne?

-- 
pozdrawiam
Roman Tyczka
Technical Details
Message-ID: <1qtlvdtvwd3ib.dlg@tyczka.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Roman Tyczka <noemail@because.no>
Newsgroups: pl.comp.bazy-danych
Subject: Funkcje WINDOW
Date: Mon, 27 Nov 2017 20:05:14 +0100
Organization: ATMAN - ATM S.A.
Lines: 29
Sender: romek@tyczka.no.found
Message-ID: <1qtlvdtvwd3ib.dlg@tyczka.com>
NNTP-Posting-Host: 94.75.90.137
Mime-Version: 1.0
X-Trace: node1.news.atman.pl 1511809514 31162 94.75.90.137 (27 Nov 2017 19:05:14 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Mon, 27 Nov 2017 19:05:14 +0000 (UTC)
User-Agent: 40tude_Dialog/2.0.15.84
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit