Suppose we have a table named "amit_bhadana_characters" with the following columns: "name", "age", and "catchphrase". Here are some sample rows:
name | age | catchphrase |
---|
Amit Bhadana | 27 | "Aalas Hatao, Life Banao" |
Babloo bhaiya | 35 | "Babloo Bhaiya ka style" |
Sameer bhaiya | 30 | "Kya bolte bantai" |
Genda bhaiya | 40 | "Hum Genda bhaiya hai" |
Now let's say we want to sort this table based on the "age" column in ascending order. We would use the following SQL statement:Copy code
SELECT * FROM amit_bhadana_characters ORDER BY age ASC;
This would give us the following result:
name | age | catchphrase |
---|
Amit Bhadana | 27 | "Aalas Hatao, Life Banao" |
Sameer bhaiya | 30 | "Kya bolte bantai" |
Babloo bhaiya | 35 | "Babloo Bhaiya ka style" |
Genda bhaiya | 40 | "Hum Genda bhaiya hai" |
Similarly, if we want to sort in descending order, we would use the following SQL statement:
SELECT * FROM amit_bhadana_characters ORDER BY age DESC;
This would give us the following result:
name | age | catchphrase |
---|
Genda bhaiya | 40 | "Hum Genda bhaiya hai" |
Babloo bhaiya | 35 | "Babloo Bhaiya ka style" |
Sameer bhaiya | 30 | "Kya bolte bantai" |
Amit Bhadana | 27 | "Aalas Hatao, Life Banao" |
So, we can see that the ORDER BY clause is used to sort the results of a SELECT statement based on one or more columns. With the help of Amit Bhadana's characters, we can understand this concept in a fun and easy way.
Comments
Post a Comment