Hi,

I just found Sequel and have been using it for some really simple
scripts.  So far it's been fantastic to quickly produce some reports.

I'm having issues doing more advanced where clauses though and haven't
been able to find any examples to help with composite primary keys
containing an effective date.

Can anyone provide insight ?

My table key structure looks like (Oracle 10g):

FIELDNAME         VARCHAR2(20)
FIELDVALUE        VARCHAR2(5)
EFFDT                  DATE

I'd like to be able to :

SELECT *
FROM MYTABLE MT1
WHERE
MT1.FIELDNAME = 'X'
AND MT1.FIELDVALUE = 'Y'
AND MT1.EFFDT =
   (SELECT MAX(MT2.EFFDT)
   FROM MYTABLE MT2
   WHERE
      MT1.FIELDNAME = MT2.FIELDNAME
      AND MT1.FIELDVALUE = MT2.FIELDVALUE)

I was trying to get something like the following to work but I'm
failing on the date formats.

   values = DB[:mytable].filter({:fieldname => 'X'} & {:effdt => DB[:
mytable].where(:fieldname => 'X').max(:effdt)})


Is there a simple way of specifying the sub query ?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to