I am using Python and SQLite, and I am trying to copy the table to another table. I have a column called InventoryNbr and I also have a column called IndexID. The other columns do not matter at this point but I would like to copy them as well. There are several duplicates of InventoryNbr. I only want distinct Inventory Numbers, but I want the MAX IndexID. I keep using this, and getting the LOWEST IndexID. How can I change this to get the max IndexID?
masterCursor.execute('INSERT INTO MasterV2 SELECT InventoryNbr, IndexListID, col1, col2, col3, col4, col5, col6, Extra FROM Master GROUP BY InventoryNbr ORDER BY IndexListID ASC')
edit:My table looks like:
InventoryNbrs | IndexListID
12345 | 123
12345 | 124
12345 | 125
12346 | 126
12346 | 127
12347 | 128
I want my new table to look like:
InventoryNbrs | IndexListID
12345 | 125
12346 | 127
12347 | 128