[SQL] CASE Select, referring to selected value

2002-07-02 Thread Nick Riemondi
Hi! I've got 2 date fields in table which constitute a term. On select I'm calculating that term, BUT I can't figure out how to refer to it in the sql - or if it's possible. I'd like to be able to use the case returned value for order, comparing, etc. Here's an example: select case when (curre

Re: [SQL] CASE Select, referring to selected value

2002-07-02 Thread Achilleus Mantzios
On Mon, 1 Jul 2002, Nick Riemondi wrote: Just rewrite your case statement in the where clause. > Hi! > I've got 2 date fields in table which constitute a term. On select I'm > calculating that term, BUT I can't figure out how to refer to it in the > sql - or if it's possible. I'd like to be ab

[SQL] Temporary table instead of repeated joins

2002-07-02 Thread Chantal Ackermann
hello all, in my program I have to check for a certain combination of data before I make an insert. The check is a select statement with a join and a function call. Now, I wonder if I could gain performance if I would create a temporary view that contained this join and the function call and

Re: [SQL] CASE Select, referring to selected value

2002-07-02 Thread Christopher Kings-Lynne
> select case when (current_date > available) then ((end_date - > current_date) / 30) > when (current_date < available) then ((end_date - available) / > 30) >end >from listing >where case > 4 > > which yields: > ERROR: parser: parse error at or near ">" > > Doe

Re: [SQL] CASE Select, referring to selected value

2002-07-02 Thread Nick Riemondi
I finally thought to try this about an hour after posting. Doh! Works perfectly. Thanks! [EMAIL PROTECTED] writes: >On Mon, 1 Jul 2002, Nick Riemondi wrote: > >Just rewrite your case statement in the where clause. > >> Hi! >> I've got 2 date fields in table which constitute a term. On select I

Re: [SQL] pg_restore cannot restore function

2002-07-02 Thread Jie Liang
I am sure. I assume that pg_restore -t mytable -d mydb mydumpfile is same as pg_restore --table=mytable --dbname=mydb mydumpfile but it is not! the 2nd one will get: pg_restore: [archiver] could not open input file: No such file or directory Jie Liang -Original Message- From: Jan W

[SQL] Why doesn't it use indexes?

2002-07-02 Thread Ahti Legonkov
Hi, I have this query: select * from reo inner join usr on reo.owner_id=usr.user_id I also have created these indexes: CREATE INDEX "owner_id_reo_key" ON reo (owner_id); CREATE INDEX "user_id_user_key" ON usr (user_id); Explain tells me this: Merge Join (cost=1341.74..1481.12 rows=299697 width