Subject | Re: SQL Update - Need Help |
---|---|
Author | L |
Post date | 2007-05-15T22:23:32Z |
Svein,
Hope your Pizza did not burn :)
Thanks. I tried that without success, but it got me thinking so I
tried this and it appears to work :
UPDATE BIZ W
SET W.MAINSIC =
( SELECT FIRST 1 P.SIC FROM BIZUNIT P
WHERE ( (P.BIZID=W.BIZID))
order by P.PAYROLL DESC)
where exists (SELECT * FROM BIZUNIT PY
WHERE ( (PY.BIZID=W.BIZID) )
AND (PY.PAYROLL > 0)
)
- Lou
--- In firebird-support@yahoogroups.com, Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
Hope your Pizza did not burn :)
Thanks. I tried that without success, but it got me thinking so I
tried this and it appears to work :
UPDATE BIZ W
SET W.MAINSIC =
( SELECT FIRST 1 P.SIC FROM BIZUNIT P
WHERE ( (P.BIZID=W.BIZID))
order by P.PAYROLL DESC)
where exists (SELECT * FROM BIZUNIT PY
WHERE ( (PY.BIZID=W.BIZID) )
AND (PY.PAYROLL > 0)
)
- Lou
--- In firebird-support@yahoogroups.com, Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
>
> Hi Lou!
>
> update biz bizzy
> set mainsic = (select sic from bizunit b1
> where b1.bizid = bizzy.bizid
> and not exists(select * from bizunit b2
> where b2.bizid = b1.bizid
> and (b2.sales > b1.sales
> or (b2.sales = b1.sales
> and b2.recid > b1.recid))))
> where exists(select * from bizunit b3 where b3.bizid = bizzy.bizid)
>
> HTH and that the pizza in my oven isn't burnt,
> Set
>