Re: upcasting multiplication in a query

From: dev(at)archonet(dot)com
To: "John Guthrie" <jguthrie(at)psynapsetech(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: upcasting multiplication in a query
Date: 2003-03-17 20:35:06
Message-ID: 49174.192.168.1.32.1047933306.squirrel@mainbox.archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-03-17 20:50:32 Re: btree_gist, gint4_union
Previous Message Carmen Sarlo 2003-03-17 20:34:40 Re: Poor performance on a right join