TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

SQL SELECT LAST

SQL select last query with sql, tutorial, examples, insert, update, delete, select, join, database, table, join

<< Back to SQL

SQL SELECT LAST

The last() function is used to return the last value of the specified column.

Syntax for SQL SELECT LAST() FUNCTION:

SELECT LAST (column_name) FROM table_name;

You should note that the last() function is only supported in MS Access. But there are ways to get the last record in MySql, SQL Server, Oracle etc. databases.

My SQL syntax:
SELECT column_name FROM table_name
ORDER BY column_name DESC
LIMIT 1;
SQL Server syntax:
SELECT TOP 1 column_name FROM table_name
ORDER BY column_name DESC;
Oracle syntax:
SELECT column_name FROM table_name 
ORDER BY column_name DESC
WHERE ROWNUM <=1;

Let us take the example of CUSTOMERS to examine SQL SELECT LAST command:

Table CUSTOMERS

CUSTOMER_NAMEAGEADDRESSEXPENDITURE
KAMAL SHARMA26GHAZIABAD6000
ROBERT PETT23NEWYORK26000
SHIKHA SRIVASTAV22DELHI9000

If you want to retrieve the last value of the "customer_name" column from the "customers" table, you need to write following query:

SELECT LAST (CUSTOMER_NAME) AS LAST_CUSTOMER FROM CUSTOMERS;
After that query, you will find the result:
SHIKHA SRIVASTAV
Next TopicSQL Select Random




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf