1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help please with SQL query for getting next record value in previous row

Discussion in 'PHP' started by Kyriakos, Dec 20, 2013.

  1. #1
    hi.

    i have this table for example:
    [​IMG]

    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:
    [​IMG]

    how i can do this with SQL or classic ASP or PHP;

    thanks in advance.
     
    Kyriakos, Dec 20, 2013 IP