LinkedIn
RSS

Difference between select single and up to 1 row

The ‘SELECT SINGLE’ statement selects the first row in the database that it finds that fulfils the ‘WHERE’ clause If this results in multiple records then only the first one will be returned and therefore may not be unique.

The ‘SELECT ….*….. UP TO 1 ROWS’ statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause or lack of, applies any aggregate, ordering or grouping functions to them and then returns the first record of the resultant result set.

Samples:


  Select single Posnr 
    from vbrp
    into w_POSNR. 

  Select Posnr 
    into table t_internal
    from VBRK
   up to 1 rows 
   order by Posnr descending.


Leave a Reply