[SQL] Re: returning the number of rows output by a copy command from a function

2013-01-17 Thread Jasen Betts
On 2013-01-16, James Sharrett wrote: > The problem I have is that I get nothing back when the COPY is run inside > the function other than what I explicitly return from the function so I > don't have anything to parse. It's odd that the record count in the > function is treated differently than f

[SQL] number of values updated per column

2013-01-17 Thread Willy-Bas Loos
Hi, I'd like to know, per column, how many values were changed by my query. I have a working example, but i am curious what you people think about it. Is it efficient? I have to make a self join, but i don't see a faster way. Here's the example: - drop table if exists tab1 ; create t

Re: [SQL] number of values updated per column

2013-01-17 Thread Akihiro Okuno
How about separating count query from update statement. I found a bit performance improvement from your example. with 10 rows, fastest time in 10 times try yours: 989.679 ms mine: 719.739 ms query --- (same DDL, DML) WITH cnt AS ( SELECT count(CASE WHEN tab1.a >= 60 THEN 1 EN

[SQL] Aggregate over a linked list

2013-01-17 Thread M Lubratt
Hello! I trade futures contracts and I have a PostgreSQL 9.2 database that keeps track of all of my trading activity. The table includes columns for the futures contract, the entry and exit dates and the profit for that particular trade. Now, futures contracts expire, so within a trade being ind

Re: [SQL] Aggregate over a linked list

2013-01-17 Thread Venky Kandaswamy
Did you try: select substring(contract from 1 for 1), min(entry_date), max(entry_date), sum(profit) from contract_table group by 1; Venky Kandaswamy Principal Engineer, Adchemy Inc. 925-200-7124 From: pgsql-sql-ow...@