Skip site navigation (1) Skip section navigation (2)

Re: variables in SQL??

From: "DalTech - CTE" <CTE(at)Dal(dot)Ca>
To: "Francisco Hernandez" <xy0xy0(at)earthlink(dot)net>
Cc: "Pgsql-sql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: variables in SQL??
Date: 2000-08-16 12:11:14
Message-ID: 00ee01c0077b$12e763e0$5911be86@cte.Dal.Ca (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-sql
> what im trying to do is have a Sum of a colum.. as it goes forwards

I don't think this is what you want, but I suppose it might help....

Table    = simple
+----------------------------------+----------------------------------+-----
--+
|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-----
--+
| price                            | int4                             |
4 |
+----------------------------------+----------------------------------+-----
--+
=> select price,count(price) from simple group by price;
price|count
-----+-----
    1|    4
    2|    7
    4|    8
    5|    5
    7|   16
    9|    1
   10|   12
(7 rows)

=> create view simple_v as select price,count(price) from simple group by
price;
CREATE 19503 1
=> select * from simple_v;
price|count
-----+-----
    1|    4
    2|    7
    4|    8
    5|    5
    7|   16
    9|    1
   10|   12
(7 rows)

=> insert into simple (price) values (5);
INSERT 19504 1
=> select * from simple_v;
price|count
-----+-----
    1|    4
    2|    7
    4|    8
    5|    6
    7|   16
    9|    1
   10|   12
(7 rows)


In response to

pgsql-sql by date

Next:From: Martin ChristensenDate: 2000-08-16 12:47:46
Subject: Many-to-one subquery
Previous:From: Volker PaulDate: 2000-08-16 11:39:24
Subject: Re: [SQL] variables in SQL??

pgsql-general by date

Next:From: Len MorganDate: 2000-08-16 12:15:13
Subject: Re: date/time functions
Previous:From: Volker PaulDate: 2000-08-16 11:39:24
Subject: Re: [SQL] variables in SQL??

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group