Re: distinct doesn't work

From: Frank Bax <fbax(at)sympatico(dot)ca>
To: "'Postgresql'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: distinct doesn't work
Date: 2007-07-08 19:45:52
Message-ID: 5.2.1.1.0.20070708154349.05526da0@pop6.sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

<html>
<body>
At 12:13 PM 7/6/07, stephen wrote:<br>
<blockquote type=cite class=cite cite><font face="arial" size=2>SELECT
distinct cc.trader_id, t.credit_card_number, t.expiry_date,
t.name_on_card,
sum(to_number(cc.debit_credit,'999999.99')),cc.approval_number,
t.business_name&nbsp; 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<br>
</font><br>
<font face="arial" size=2>And I expect to get one line as I only have I
trader-id in my table(s) but I get this:<br>
</font><br>
<font face="arial" size=2>1493 4321442143314432 09/09 two duck -200&nbsp;
2 Duck Trading Company <br>
</font><br>
<font face="arial" size=2>1493 4321442143314432 09/09 two duck 200 5678 2
Duck Trading Company<br>
</font><br>
<font face="Times New Roman, Times">In fact I dont actually expect to get
any response as the sum should have summed to zero.<br>
</font><br>
<font face="arial" size=2>Does anyone know what I am doing wrong?
</font></blockquote><br><br>
It's hard to say for sure because to don't have column delimiters in
output; but it kinda looks like the first result is sum of all rows
without an approval_number and the second ro has approval_number
5678</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.3 KB

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tjibbe 2007-07-08 21:24:12 Re: REVOKE on ALTER USER, DROP USER
Previous Message Tjibbe 2007-07-08 19:36:34 Re: REVOKE on ALTER USER, DROP USER