🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: PostgreSQL - jak zredagować SQL?

#194657
From: Marek
Date: Thu, 24 Sep 2015 10:12
16 lines
1316 bytes
>
> wtedy:
> with users_to_update as ( subquery ),
>      update_by as (select user_id, count(*) from users_to_update group by
>      user_id)
> update ratings r
> set games = r.games + x.count
> from update_by as x
> where x.user_id = r.user_id;

Sprytne! Właśnie podobnie z tym WITH'em kombinowałem lecz zawsze jakaś 
pułapka mnie przytrzasnęła - dziś przeeksperymentuję w/w wariant i dam znać.

-- 
Pozdrawiam,
Marek
Technical Details
Message-ID: <mu0i9n$5lq$1@news.icm.edu.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!.POSTED!not-for-mail
References: <mtrd71$eu8$1@news.icm.edu.pl> <t75adc-515.ln1@depesz.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!.POSTED!not-for-mail
From: Marek <precz@spamowi.com>
Newsgroups: pl.comp.bazy-danych
Subject: Re: PostgreSQL - jak zredagować SQL?
Date: Thu, 24 Sep 2015 12:12:03 +0200
Organization: ICM, Uniwersytet Warszawski
Lines: 16
Message-ID: <mu0i9n$5lq$1@news.icm.edu.pl>
References: <mtrd71$eu8$1@news.icm.edu.pl> <t75adc-515.ln1@depesz.com>
NNTP-Posting-Host: 89-69-222-145.dynamic.chello.pl
Mime-Version: 1.0
X-Trace: news.icm.edu.pl 1443089527 5818 89.69.222.145 (24 Sep 2015 10:12:07 GMT)
X-Complaints-To: usenet@news.icm.edu.pl
NNTP-Posting-Date: Thu, 24 Sep 2015 10:12:07 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
In-Reply-To: <t75adc-515.ln1@depesz.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit