You are here: Re: Stumped by SQL challenge « MsSQL Server « IT news, forums, messages
Re: Stumped by SQL challenge

Posted by Hugo Kornelis on 09/29/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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация