title: How to create an IF-ELSE statement if there are two similar MAX value, hence find the MIN value from the database
body: <p>I have four column in my database, 'UniqueID','Exam', 'Percent1' and 'Time1'. I am able to display the MAX value from the database easily, hence able to get the the best 'Exam' result.</p>
  
  <p>But now I encounter a problem where if there are similar MAX value, which 'Exam'to choose. Hence I though if this problem occur, I would pick the MIN from the 'Time1' column, which is the same row as the MAX value. But I am not sure how to do this. </p>
  
  <p>I tried something like this, but unfortunately there was an error. Any suggestions or hints is extremely appreciated. Thank you</p>
  
  <pre><code>var userID = "hello";
      string maxnum, name;
  
      string SqlString = "SELECT max(Test3)from Table2 WHERE Test1 = @ID AND min(Test4)";
  
      using (objCon = new OleDbConnection(ConnectString))
      {
          using (objCmd = new OleDbCommand(SqlString, objCon))
          {
              objCmd.Parameters.AddWithValue("@ID", userID);
              objCon.Open();
  
              maxnum = objCmd.ExecuteScalar().ToString();
              Label1.Text = maxnum;
          }
      }
  </code></pre>