How to delete an older min value from record?

tamadon

Active Member
Licensed User
Longtime User
Say I have the following table

score | someval
----- ---------
20 | 15
25 | 5
50 | 23
33 | 33
20 | 50

I want to delete min score which is 20 where someval is the lowest among the duplicates (if duplicate score exist). In the table above, it would be the first row.

I think I know how to delete the min score record but the second condition I am not sure how to integrate into my query

Code: Copy
sqlScore.ExecNonQuery("DELETE FROM scorestable WHERE score = (SELECT min(score) FROM scores AND min(someval)")
???

Thank you for your help.
 
Thanks Erel. But what if we have several duplicate lowest scores, how does the code select which one is the older one to delete? BTW, I have included a DateTime.Now column so I am comparing the age using that column.
 
Upvote 0
Thanks Erel, but I am not too familiar with SQL Lite database. I already have the highscore working based on this code

But now I am trying to delete a particular record based on the condition. How to format this statement correctly?

Code: Copy
sqlScore.ExecNonQuery("DELETE FROM scorestable WHERE score = (SELECT min(score) FROM scores AND min(someval)")

Sorry if I am asking an obvious question.. :sign0085:
 
Upvote 0
Back
Top