[SQL] Aggregate query for multiple records

2004-08-25 Thread Scott Gerhardt
Hello, I am new to the list, my apology if this question is beyond the scope or charter of this list. My questions is: What is the best method to perform an aggregate query to calculate sum() values for each distinct wid as in the example below, but except for all wid's (not just WHERE wid='01/

Re: [SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Tom Lane
Adrian Klaver <[EMAIL PROTECTED]> writes: > I don't know what to make of it but the problem seems to start at the lines I > have marked 1 & 2 and involves the lo_import function. I have not used > lo_import and so do not know how to call it. What I do see is that it is > called at 1 and a '('

Re: [SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Adrian Klaver
On Wednesday 25 August 2004 07:21 pm, Tom Lane wrote: > "Kathrine S" <[EMAIL PROTECTED]> writes: > > Below is a copy of my sql sentence including the error I am getting. What > > does the error mean? What have I done wrong? > > > > kathrirs=# insert into faglaerer > > kathrirs-# values ('f-001', '1

Re: [SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Tom Lane
"Kathrine S" <[EMAIL PROTECTED]> writes: > Below is a copy of my sql sentence including the error I am getting. What > does the error mean? What have I done wrong? > kathrirs=# insert into faglaerer > kathrirs-# values ('f-001', '13056802876', 'Petter Lær', > lo_import('/home/studenter/it03/kathri

Re: [SQL] CREATE TYPE VARCHAR2

2004-08-25 Thread Tom Lane
Sascha Ziemann <[EMAIL PROTECTED]> writes: > I would like to define a > new type VARCHAR2 which should behave exactly like VARCHAR. You could get about halfway there with CREATE DOMAIN varchar2 AS varchar; But it's only halfway because the domain will not accept length decorations; that i

[SQL] Optimizer Selecting Incorrect Index

2004-08-25 Thread David Price
I have 2 servers both with the exact same data, the same O.S., the same version of Postgres (7.4.5) and the exact same db schema's (one production server, one development server). One server is using the correct index for SQL queries resulting in extremely slow performance, the other server is pro

[SQL] refer to computed columns

2004-08-25 Thread Bruno Mueller
Hi Think of the following query: 1 select 2 country, 3 (select sum(salary) from employees) as totalSalary, 4 sum(salary) as countrySalary, 5 countrySalary / totalSalary as countryPct 6 from employees 7 group by country 8 order by country ; I know it does not work, but is there a way to refer to

[SQL] CREATE TYPE VARCHAR2

2004-08-25 Thread Sascha Ziemann
Hi, I try to emulate with PostgreSQL an Oracle database. My problem is that PostgreSQL does not support any Oracle specific types. PostgreSQL provides the TEXT and Oracle uses the CLOB or VARCHAR2 type. I would like to use the CREATE TYPE statement to tell PostgreSQL about the Oracle types, but

[SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Kathrine S
Below is a copy of my sql sentence including the error I am getting. What does the error mean? What have I done wrong? kathrirs=# insert into faglaerer kathrirs-# values ('f-001', '13056802876', 'Petter Lær', lo_import('/home/studenter/it03/kathrirs/img/img01.jpg'), kathrirs(# '2001-12-25', 100, '

[SQL] view triggers/procedures

2004-08-25 Thread SVGK, Raju (Raju)
Hi, I have a table where in lot of triggers were included in that as shown below. How to view/access triggers and procedures from postgresql. I am using postgresql 7.4.1 on solaris. regds -raju Process=# \d reviews Table "public.reviews" Column

[SQL] help with scheme changes to live system.

2004-08-25 Thread Tony Yang
Hi Gurus, Please forgive this naive question: Say, I have a table (containerId, itemId) where for each containerId there are several rows (different itemId value) in that table. Now I want to give those rows (with same containerId) a sequence, so add one colum there to make it become (containerI

Re: [SQL] olympics ranking query

2004-08-25 Thread Mischa Sandberg
That 'running aggregate' notion comes up quite regularily, and it has a number of nonintuitive holes, to do with what happens when your ordering allows for ties. ASTRID had it, RedBrick SQL had it, the latest MSSQL has it ... not necessarily a recommendation. Tom Lane wrote: David Garamond <[EMAIL

[SQL] problem with RULE

2004-08-25 Thread Sreten Milosavljevic
I have two tables. One is test_main, and second is named result. Also I have view which summarizes results from test_main table and groups them by ID column: CREATE TABLE test_main(id varchar(4), value int4); CREATE TABLE result(id varchar(4), value int4); CREATE VIEW su

Re: [SQL] Complicated "group by" question

2004-08-25 Thread Andrew Perrin
Excellent - thanks, Josh! -- Andrew J Perrin - http://www.unc.edu/~aperrin Assistant Professor of Sociology, U of North Carolina, Chapel Hill [EMAIL PROTECTED] * andrew_perrin (at) unc.edu On Wed, 25 Aug 2004, Josh Berkus wrote:

Re: [SQL] Complicated "group by" question

2004-08-25 Thread Jean-Luc Lachance
Andrew, If assing is not a many to many relation, why did you not fold accept_id into assign? Any way, here is the query you need: select assign.reviewer_id, ss.max_assign_date, accept.assign_id, accept.accept_id from ( select reviewer_id, max( assign_date) as max_assign_date from assign grou

Re: [SQL] Complicated "group by" question

2004-08-25 Thread Josh Berkus
Andrew, > I have a table of people ("reviewers"), a table of review assignments > ("assign"), and a table of review acceptances ("accept"). I would like to > be able to write a query to return the latest (e.g., max(assign_date)) > assignment for each reviewer, plus the acc_id field from "accept".

[SQL] Complicated "group by" question

2004-08-25 Thread Andrew Perrin
I have a table of people ("reviewers"), a table of review assignments ("assign"), and a table of review acceptances ("accept"). I would like to be able to write a query to return the latest (e.g., max(assign_date)) assignment for each reviewer, plus the acc_id field from "accept". I think I should

Re: [SQL] PQexec and SPI_exec

2004-08-25 Thread Jan Wieck
On 8/25/2004 10:21 AM, Pedro B. wrote: Hello everyone. I'm experiencing some doubts regarding a procedure i have (.c compiled as .so) running as an 'after insert for each row' trigger. This trigger is supposed to do a simple query, something like SELECT * FROM table order by id where processed=0

[SQL] PQexec and SPI_exec

2004-08-25 Thread Pedro B.
Hello everyone. I'm experiencing some doubts regarding a procedure i have (.c compiled as .so) running as an 'after insert for each row' trigger. This trigger is supposed to do a simple query, something like SELECT * FROM table order by id where processed=0 limit 1 It's not the perfect way to get