Re: [JDBC] mathematical calculations - sql queries

Lists: pgsql-adminpgsql-jdbc
From: vbhatia(at)ksu(dot)edu
To: pgsql-jdbc(at)postgresql(dot)org
Subject: mathematical calculations - sql queries
Date: 2007-07-30 02:07:40
Message-ID: 1185761260.46ad47ec4a9b7@webmail.ksu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin pgsql-jdbc

Hi all,

Thanks for replying to previous mail, I have one more question. Can I
write a postgresql query that retrieves a particular field from a table
and performs some mathematical calculation on that field involving
exponential( exp) and pow functions and storing the result in a new
table.

Somethign like this
select field1 from tablename1 ( performing calculation on field1 ) (
storing in another table)

Thanks and regards,
Vishal


From: "Andres Olarte" <olarte(dot)andres(at)gmail(dot)com>
To: "vbhatia(at)ksu(dot)edu" <vbhatia(at)ksu(dot)edu>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: mathematical calculations - sql queries
Date: 2007-07-30 02:38:46
Message-ID: 3fccaa690707291938s437884bsbcd923160b0a097c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin pgsql-jdbc

Sure, this is not a jdbc question, but it's fairly easy:

INSERT INTO table2 (col_name2) SELECT power(col_name1,3) FROM table1;

On 7/29/07, vbhatia(at)ksu(dot)edu <vbhatia(at)ksu(dot)edu> wrote:
> Hi all,
>
> Thanks for replying to previous mail, I have one more question. Can I
> write a postgresql query that retrieves a particular field from a table
> and performs some mathematical calculation on that field involving
> exponential( exp) and pow functions and storing the result in a new
> table.
>
>
> Somethign like this
> select field1 from tablename1 ( performing calculation on field1 ) (
> storing in another table)
>
>
> Thanks and regards,
> Vishal
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>


From: "Srinivas Kotapally" <ksrinivas(at)coriendo(dot)com>
To: <vbhatia(at)ksu(dot)edu>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [JDBC] mathematical calculations - sql queries
Date: 2007-07-30 10:54:43
Message-ID: 022001c7d298$0a054d10$3221a8c0@srinilaptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-admin pgsql-jdbc

You could do a stored procedure for inserting into another table... Otherwise if
you want to get the result as a query, you could do something like,
Select field1, exp(field2) as expoffield2 from tablename1

Hope that helps,

Srini

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org [mailto:pgsql-jdbc-owner(at)postgresql(dot)org]
On Behalf Of vbhatia(at)ksu(dot)edu
Sent: Sunday, July 29, 2007 10:08 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] mathematical calculations - sql queries

Hi all,

Thanks for replying to previous mail, I have one more question. Can I write a
postgresql query that retrieves a particular field from a table and performs
some mathematical calculation on that field involving exponential( exp) and pow
functions and storing the result in a new table.

Somethign like this
select field1 from tablename1 ( performing calculation on field1 ) ( storing in
another table)

Thanks and regards,
Vishal

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match