| From: | John Edstrom <edstrom(at)Poopsie(dot)hmsc(dot)orst(dot)edu> |
|---|---|
| To: | pgsql-sql(at)postgreSQL(dot)org |
| Subject: | Re: [SQL] locked my keys in the car |
| Date: | 1998-08-03 18:54:31 |
| Message-ID: | 199808031854.LAA03398@Poopsie.hmsc.orst.edu |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
>
> And so I tried this here:
>
> SELECT tr_id, tr_date FROM crtrd1
> WHERE tr_unit = 'SMA' AND (tr_type = 'A' OR tr_type = 'I')
> AND tr_date > tr_date IN
> (SELECT tr_date FROM crtrd1
> WHERE tr_unit = 'SMA' AND (tr_type = 'T' OR tr_type = 'O'))
> ORDER BY tr_date DESC;
>
How about
CREATE FUNCTION F(int,char) returns int4 as
'SELECT max(tr_date) FROM crtd1
WHERE $1=tr_id
AND $2=tr_unit
AND (tr_type = \'A\' OR
tr_type = \'I\');'
language 'sql';
and then search as:
SELECT distinct tr_id,F(tr_id) from crtd1;
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Roderick A. Anderson | 1998-08-03 18:56:07 | Re: [SQL] can a column be aliased? |
| Previous Message | Daniele Orlandi | 1998-08-03 18:51:12 | Re: [SQL] Low level socket locking... |