Subject | Svein : Re: [firebird-support] Re: Substraction of 2 selections |
---|---|
Author | rpoulin |
Post date | 2004-04-30T13:48:06Z |
Thanks Svein, but what i need to do is a real substraction ('minus'
operator) , not a set.
i.e. :
(Price from Select 1) - (Price from Select 2) The result is written
in a numeric field (called DELTA_PRICE)
-----------------------------
Svein Erling wrote:
operator) , not a set.
i.e. :
(Price from Select 1) - (Price from Select 2) The result is written
in a numeric field (called DELTA_PRICE)
-----------------------------
Svein Erling wrote:
> --- In firebird-support@yahoogroups.com, rpoulin wrote:
> > I want to substract those two following selections from my KIT
> > table and put the result in a new field called DELTAPRICE. Do i need
> > to create a function to take care of the script ?
> >
> > select DETAIL_KIT.PRIX_MARGE_DETAIL, DETAIL_KIT.PRINCIPAL from
> > DETAIL_KIT where PRINCIPAL ='O' order by NO_ORDRE
> >
> > [ minus ]
> >
> > select DETAIL_KIT.PRIX_MARGE_DETAIL, DETAIL_KIT.PRINCIPAL from
> > DETAIL_KIT where PRINCIPAL ='N' order by NO_ORDRE
> >
> > THANK ..... a lot ...
> > Richard P
>
> Simple, Richard, just do
>
> select DK1.PRIX_MARGE_DETAIL, DK1.PRINCIPAL from
> DETAIL_KIT DK1
> where DK1.PRINCIPAL ='O'
> and not exists (select * from DETAIL_KIT DK2
> where DK2.PRIX_MARGE_DETAIL = DK1.PRIX_MARGE_DETAIL
> and DK2.PRINCIPAL ='N')
> order by NO_ORDRE
>
> HTH,
> Set
>
>
> ------------------------------------------------------------------------
> *Yahoo! Groups Links*
>
> * To visit your group on the web, go to:
> http://groups.yahoo.com/group/firebird-support/
>
> * To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
> <mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>