Subject | Re: [firebird-support] FireBird SQL help |
---|---|
Author | Magnus Titho |
Post date | 2006-02-07T16:54:03Z |
william_yuwei wrote:
select t1.*
from yourtable t1
where exists(select t2.* from yourtable t2 where (t2.ModelNo =
t1.ModelNo) and ((t2.ColA < 1) or (t2.ColB < 1) or (t2.ColC < 1)))
"yourtable" is either the table with your original data or the stored
procedure itself.
--
Magnus
> I've built a stored procedure which returned the following result:Maybe with something like this:
>
> ModelNo Color Size ColA ColB ColC
> 8080 Gold 48 2.5 2.2 2.4
> 8080 Gold 50 3.4 3.7 3.2
> 8080 Gun 48 0.8 0.9 0.9
>
> 8081 Blue 47 1.9 2.0 1.9
> 8081 Blue 49 2.7 3.0 2.8
>
> However there is another critera needs to be used against above
>results: if any of ColA, ColB or ColC are lower than 1.0, the whole
>group of model will be returned otherwise not, which means that Model
>8081 should not be returned to the final result, while whole records
>of Model 8080 should be returned.
>
>How can I implement this by SQL?
>
>
select t1.*
from yourtable t1
where exists(select t2.* from yourtable t2 where (t2.ModelNo =
t1.ModelNo) and ((t2.ColA < 1) or (t2.ColB < 1) or (t2.ColC < 1)))
"yourtable" is either the table with your original data or the stored
procedure itself.
--
Magnus