|
Posted by Hugo Kornelis on 10/01/08 11:27
On 20 Sep 2005 09:10:49 -0700, imani_technology_spam@yahoo.com wrote:
>Thank you for the information. I'm wondering how this would work as a
>SELECT statement. Also, let's assume there is a foreign key constraint
>on fk_parent_id. And the pk field is a primary key.
Hi imani,
A better way to get replies is to post your complete table structure,
including keys and relationships, as DDL. Also, supply sample data as
INSERT statements and expected output.
Here's a wild guess:
SELECT other columns,
CASE
WHEN code = 5
AND EXISTS
(SELECT *
FROM child AS C
WHERE fk_parent_id = child.fk_parent_id
AND code > child.code
AND dt < child.dt)
THEN 10
ELSE newcode
END AS newcode
FROM child
(untested)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Navigation:
[Reply to this message]
|