I need to build invoice table based on accounts payable table. Depends on value in some fields, I need to populate invoice amount field. Actualy I have a RPG program printout and I need to translate this program in SQL code. Part of RPG program adds line count to program. If record line for particular voucher number=1, them value of amount field in input file popupates X field, if line<>1 then value in amt field populates some Y field. How I can code this procedure in SQL?