I have a result from the SQL query, which is displayed below,
I want to build a SQL query, which can return the row includes maximum number from the last column if any two rows (or more than 2) have the same number from the first column.
For instance, from the table, you can see the top two rows have the same number from the first column, which is 2195333
. If the SQL query runs, it will return the first row and the rest of rows, discarding the 2nd row only, since the last column for the 2nd row is 1, which is smaller than 2 from the 1st row.
I was thinking about using the while loop in SQL, like run the loop from the 1st row to the last row, if there are any rows have the same value from the first column, it will return the row which has the maximum value from the last column. Since I am new to SQL, I have no idea how to implement it. Please me help me. Thanks