Posts

Showing posts from November, 2022

Some Interesting and Useful SQL Commands

Image
  SQL or in other words Structured Query Language is an essential skill which every developer would like to have in their arsenal. Its a powerful language to interact with SQL Database. Despite its popularity lot of developers struggle to use some basic commands. Here we are going to see some interesting and Useful SQL commands and their use with the help of an example. Let me state the problem statement first and then we can try to solve the problem using SQL Query. Problem Statement We are given a table which describes the Train Departure Timings from different stations as shown in the figure below: We are asked to return the results of second most recently departed train from each station. So from the example table above the result would contain the following records: Lets see how we can get the result using SQL. Solution First of all we need to group the records based on the station name. Along with that we need to sort each group based on the departure timings. In this case we...