MySQL Select Value and Decrement

I have a label that runs a query on property change and shows a part’s max qty for a certain product. Below this I have a drop down menu for order quantity, and I don’t want a quantity to be ordered that is more than what the product takes. So if the query returns a max qty of 4, then the drop down menu should have a dataset of [0,1,2,3,4]. Any ideas on how to return a dataset from a value selected by query that is decremented down to zero? thanks

maxQuantity = 4 # replace with the result of your query
dropdown = event.source.parent.getComponent('ddlQuantity') # or whatever your dropdown is called
quantities = [[x] for x in range(maxQuantity+1)]
dropdown.data = system.dataset.toDataSet(["Quantity"], quantities)

Ah, I didn’t even think about doing it in scripting after running the query. I was trying to do it in the query itself. Cool thanks!