Subject Re: [firebird-support] How to update this column?
Author Mercea Paul
On 2011-04-11 6:03 PM, W O wrote:
>
> Hello everybody
>
> I have the table MOVIMCAB (MVC_IDENTI, MVC_DATE)
>
> The table MOVIMDET (MOV_IDENTI, MOV_PRODUCTCODE, MOV_COUNT)
>
> The table PRODUCTS (PRD_CODE, PRD_COUNT)
>
> And I want to update each column PRD_COUNT with the last MOV_COUNT
>
> UPDATE PRODUCTS SET PRD_COUNT = the last MOV_COUNT
>
> for each product code.
>
> Thanks in advance.
>
> Walter.
>
update products p
set p.prd_count= (select first 1 d.mov_count from movimdet d join
movimcab c on d.mov_identi=c.mvc_identi
where d.mov_productcode=p.prd_code
order by c.mvc_date desc)

Hope is working
Regards,

--

Mercea Paul




[Non-text portions of this message have been removed]