Reputation: 75
We have a table that is like this:
Customer ItemNumber Item_Name Qty FOCQty
C1 I1 ABC 10 2
C2 I2 BCA 12 2
C3 I1 ABC 3 3
C4 I2 BCA 05 1
But we want it to be like this:
ItemNumber Item_Name Qty FOCQty
I1 ABC 13 5
I2 BCA 17 3
We tried the following:
tx.executeSql('SELECT ItemNumber,Item_Name,sum(Qunatity) as Qunatity1 ,sum(FOCQty) as FOCQty1\
from toCSV5\
Where ItemNumber=?',[this.UpdateItemNumber],SumSuccess,errorCB);
but it did not work for us. Please tell us what is wrong in our code.
Upvotes: 1
Views: 1043
Reputation: 3833
fix
- adjust dynamic sql string to add group by on fields
ItemNumber,Item_Name
as below
static query
SELECT ItemNumber,Item_Name,sum(Qunatity) as Qunatity1 ,sum(FOCQty) as FOCQty1
from toCSV5
where ItemNumber = 'I1'
group by ItemNumber,Item_Name
;
output
+------------+-----------+-----------+---------+
| ItemNumber | Item_Name | Qunatity1 | FOCQty1 |
+------------+-----------+-----------+---------+
| I1 | ABC | 13 | 5 |
+------------+-----------+-----------+---------+
sqlfiddle link
Upvotes: 1