hi. i have this table for example: and this SQL query: prcrSql = "SELECT scaleqty, fld01, dim2, dim1, prcrule, finaldate FROM prcrdata WHERE finaldate>=getDate()-1 AND (dim1=30 OR dim1=40) ORDER BY dim2" prcrRS.Open prcrSql WHILE NOT prcrRS.EOF insPRCR = "INSERT INTO prcr (mtrl,ofprice,minqty,maxqty,client,prcrule,fdate) VALUES ('"&prcrRS("dim2")&"','"&prcrRS("fld01")&"','"&prcrRS("minqty")&"','"&prcrRS("maxqty")&"','"&prcrRS("dim1")&"','"&prcrRS("prcrule")&"','"&prcr("prdate")&"')" myCon.Execute insPRCR prcrRS.MoveNext WEND Code (markup): in the table above (image table) i have only the minqty (minimum quantity) and i want to set the maxqty (maximum quantity) 1 less than minqty of the next record. for example at row 1: 4 (5-1) at row 2: 7 (8-1) and so on... i want this result: how i can do this with SQL or classic ASP or PHP; thanks in advance.