pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedupcasting multiplication in a query
3+ messages / 3 participants
[nested] [flat]
* upcasting multiplication in a query
@ 2003-03-17 20:21 John Guthrie <jguthrie@psynapsetech.net>
2003-03-17 20:35 ` Re: upcasting multiplication in a query dev@archonet.com
2003-03-17 20:51 ` Re: upcasting multiplication in a query Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 3+ messages in thread
From: John Guthrie @ 2003-03-17 20:21 UTC (permalink / raw)
To: pgsql-sql
i have a schema that stores timestamps in seconds/microseconds format. each
column in the table is int4. what i want to do is to compute the int8 value
of total microseconds, a la:
select (seconds*1000000)+micros from my_table;
but it looks to me like postgresql puts the rresult into another int4 (since
i am getting negative numbers, i assume overflow). how can i get it to use
int8?
thanks.
---
john guthrie
jguthrie@psynapsetech.net
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: upcasting multiplication in a query
2003-03-17 20:21 upcasting multiplication in a query John Guthrie <jguthrie@psynapsetech.net>
@ 2003-03-17 20:35 ` dev@archonet.com
1 sibling, 0 replies; 3+ messages in thread
From: dev@archonet.com @ 2003-03-17 20:35 UTC (permalink / raw)
To: John Guthrie <jguthrie@psynapsetech.net>; +Cc: pgsql-sql
> i have a schema that stores timestamps in seconds/microseconds format.
> each
> column in the table is int4. what i want to do is to compute the int8
> value
> of total microseconds, a la:
> select (seconds*1000000)+micros from my_table;
> but it looks to me like postgresql puts the rresult into another int4
> (since
> i am getting negative numbers, i assume overflow). how can i get it to use
> int8?
Try (seconds::int8 * 10000000)+micros - you could use cast(...) if you
want to be more standard.
- Richard Huxton
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: upcasting multiplication in a query
2003-03-17 20:21 upcasting multiplication in a query John Guthrie <jguthrie@psynapsetech.net>
@ 2003-03-17 20:51 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2003-03-17 20:51 UTC (permalink / raw)
To: John Guthrie <jguthrie@psynapsetech.net>; +Cc: pgsql-sql
"John Guthrie" <jguthrie@psynapsetech.net> writes:
> select (seconds*1000000)+micros from my_table;
> but it looks to me like postgresql puts the rresult into another int4 (since
> i am getting negative numbers, i assume overflow). how can i get it to use
> int8?
Cast the constant to int8.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-03-17 20:51 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-17 20:21 upcasting multiplication in a query John Guthrie <jguthrie@psynapsetech.net>
2003-03-17 20:35 ` dev@archonet.com
2003-03-17 20:51 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox