TechSpider
A searchable, categorised online resourse for finding technical information and solutions to problems
Welcome! You are viewing the Database category.
Below are the PostgreSQL and Novice PL/pgSQL question and example related pages
Custom Search
You can search the database for more PostgreSQL articles using the box below:
Custom Search

PostgreSQL Articles:
An interesting approach, one of which I wouldn't have conceived.
I am trying to understand how it works. You calculate a first
approximation based on discarding the fractional penny, and
then adjust that by adding on a whole penny in some cases, so
that the sum of the shares matches the original amount that
was divided.

Actually, on my 8.3.9, it doesn't work:

pnwc=> SELECT G.A, TRUNC(90.0 / 7, 2) +
pnwc-> CASE
pnwc-> WHEN ROW_NUMBER() OVER (ORDER BY G.A) <= 100 * (90 - 7 * TRUNC(90.0 / 7, 2)) THEN
pnwc-> 0.01
pnwc-> ELSE
pnwc-> 0.00
pnwc-> END
pnwc-> FROM generate_series(1, 7) AS G(A);
ERROR: syntax error at or near "OVER"
LINE 3: WHEN ROW_NUMBER() OVER (ORDER BY G.A) <= 100 ...
^

What version are you running, or what am I doing wrong that
prevents me from reproducing your results?

Thanks!

Jim



To make changes to your subscription:



Article list Name Date
Click Here James Long 2010-02-08 01:33:29
Click Here James Long 2010-02-08 03:14:46
Click Here Tom Lane 2010-02-08 06:51:16
Click Here James Long 2010-02-08 07:57:45
Click Here James Long 2010-02-08 19:31:29
Click Here Tim Landscheidt 2010-02-08 21:17:38
Currently Viewing : This ArticleJames Long2010-02-08 21:44:09
Click Here Tim Landscheidt 2010-02-09 00:45:12
Click Here Jasen Betts 2010-02-11 11:31:04


Copyright Techspider V0.81   |   Techspider Sitemap