Skip to content
Advertisement

How can I prioritize the maximum of multiple columns in SQLite

I have a little issue with my SQLite query which I use in python. In my little test_table I got 4 columns: sys_id, aq, vq, off_id. If I search for example for off_id=7477310

I get results:

But I would also like a direct comparsion by this priority (vq,aq,sys_id) so I tought I use max. So the goal is if one result has the highest vq it directly wins, if vq ar identicial with more than one row next is aq, if aq is higher direct win, and last is sys_id if vq and aq is the same sys_id the highest sys_id wins.

Any ideas?

Thanks a lot

Advertisement

Answer

It looks like you want order by and limit:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement