pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Graeme Merrall <gmerrall@email.com>
To: pgsql-sql@postgreSQL.org
Subject: round() and ||
Date: Thu, 20 Jan 2000 15:42:56 +1300
Message-ID: <000f01bf62f0$0ebfff00$899d60cb@inspire.net.nz> (raw)

Hi.
I'm having a lot of trouble concatenating some fields along witha rounded number. services_cost is a float field field and I want to convert it to 2 decimal places so it appears as money. I could store it as money but mathematical operations are performed on the same field further down the line so I don't want it 'pre-formatted'

SELECT round(services_cost,2) as test_field FROM services
works fine but 
SELECT round(services_cost,2)::text as test_field FROM services
as various other variations does not. 

The reason I need to do this is so join this field and a text field together
SELECT services_type || '|' || round(services_cost,2)  AS services_list FROM services;

but pgsql complains that it can't join a numeric plus a text field obviously. I'm pretty stuck on this one.

Cheers,
 Graeme

view thread (2+ messages)  latest in thread

Message-ID: <000f01bf62f0$0ebfff00$899d60cb@inspire.net.nz>
Permalink:  ../000f01bf62f0$0ebfff00$899d60cb@inspire.net.nz/
Also on:    postgresql.org/message-id/000f01bf62f0$0ebfff00$899d60cb@inspire.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: gmerrall@email.com
  Subject: Re: round() and ||
  In-Reply-To: <000f01bf62f0$0ebfff00$899d60cb@inspire.net.nz>
  References: <000f01bf62f0$0ebfff00$899d60cb@inspire.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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