What I am trying to accomplish is to grab the first N number of records, group by name, and total the qty value. The below statement grabs all of the records but only displays the first N number of grouped and totaled records. I tried moving the LIMIT statement around but kept getting errors. Was wondering if anyone could see what I am doing wrong.
My thought is to use the following statement to grab N number of records, dumping the results into a new table then group and total from that. I hope to avoid the extra step if my above code will work.
B4X:
sSQL = "SELECT name, qty, SUM(qty) as qty FROM items GROUP BY name ORDER BY qty DESC LIMIT " & "'" & iNum & "'" & """
My thought is to use the following statement to grab N number of records, dumping the results into a new table then group and total from that. I hope to avoid the extra step if my above code will work.
B4X:
sSQL = "Select name, qty, FROM items LIMIT " & "'" & iNum & "'" & """