Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SQL Last ( ) Function

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 230
    Comment on it

    It work similar to Last ( ) function but it return the last column from a table in database .
    Syntax

    select last ( col_name ) from table_name ;
    

    It support in Ms Access Database . But for other database there is different statement for Last ( ) function .
    Syntax For MySQL Database

    select col_name from table_name order by col_name desc limit 1 ; // desc mean in descending order
    

    Syntax for SQL Database

    select  top 1 col_name from table_name order by col_name desc ; // desc mean in descending order
    

    Syntax for Oracle Database

    select  col_name from table_name order by col_name desc where rownum <= 1 ; 
    

    Example ->
    Table name -> student

    **Student_name**     **Student_Age**    **Student_Id**
       Mukesh                    23                 1
       Ayush                     24                 2
       Ishan                     20                 4
       Pranav                    35                 7   
       Abhishek                  26                 8
       Ravi                      25                 3
    

    Suppose you want to retrieve last element from student table then you can do easily by Last ( ) function

    select last ( Student_name ) as last_student from student ; 
    

    Output ->

    Ravi
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: