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

distinct doesn't work

From: "stephen" <mail(at)xesoftware(dot)com(dot)au>
To: "'Postgresql'" <pgsql-novice(at)postgresql(dot)org>
Subject: distinct doesn't work
Date: 2007-07-06 16:13:06
Message-ID: 000001c7bfe8$902f10f0$cd0b690a@tablet (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I am doing this:
SELECT distinct cc.trader_id, t.credit_card_number, t.expiry_date,
t.business_name  FROM credit_card_history AS cc INNER JOIN traders AS t
USING (trader_id) GROUP by cc.trader_id, t.credit_card_number,
t.expiry_date, t.name_on_card, cc.approval_number, t.business_name
having sum(to_number(cc.debit_credit,'999999.99')) != 0
And I expect to get one line as I only have I trader-id in my table(s)
but I get this:
1493 4321442143314432 09/09 two duck -200  2 Duck Trading Company 
1493 4321442143314432 09/09 two duck 200 5678 2 Duck Trading Company
In fact I don't actually expect to get any response as the sum should
have summed to zero.
Does anyone know what I am doing wrong? 
Stephen Choularton
0413 545 182
02 9999 2226


pgsql-novice by date

Next:From: stephenDate: 2007-07-06 16:16:21
Subject: identifying last entry in a table
Previous:From: Raimon FernandezDate: 2007-07-06 06:11:27
Subject: Re: subquery with more than one column

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