Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

select stmt

Former Member
0 Kudos

what is the difference between select single and select up to 1 row?

its urgent plz?

thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

Hope this helps

Vinodh Balakrishnan

3 REPLIES 3

Former Member
0 Kudos

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.

Hope this helps

Vinodh Balakrishnan

Former Member
0 Kudos

hi kaladhar,

Both select single and select up to 1 rows retrieves single record but the difference is in its usage.

Usually these select statements are used for screen validations.

if a particular field has check table then we use select single statement.

if a particular field doesn't have check table then we use select up to 1 rows.

reward if helpful

shashikanth naram.

Former Member
0 Kudos

Select single statement, you need to give all primary key to select unique records. It is always selecting a single record based on your WHERE condition.

Select up to one row is mainly used for aggrecate function like sum up or count . It is also giving single record which is latest record in your table. if you wnat to retrival oldest one record, you need to use group by statement.