Dear it my first time to use alasql and i need some help
my console 0: b :16 idCatQuestion: undefine
i have a output json with this structure
var c= [
{
"0": "1",
"1": {
"idCatQuestion": "1",
"idSousCatQuestion": "1",
"designation": "objectifs 1"
}
},
{
"0": "2",
"1": {
"idCatQuestion": "1",
"idSousCatQuestion": "2",
"designation": "Objectifs 2"
}
},
{
"0": "3",
"1": {
"idCatQuestion": "2",
"idSousCatQuestion": "3",
"designation": "Objectif 3"
}
},
]
i would like with alasql to make a query, this is my code
var res = alasql('SELECT idCatQuestion, COUNT(*) AS b FROM ? GROUP BY idCatQuestion',[c]);
console.log(res);
The issue you're encountering is due to the structure of your data and how you're accessing it in your query.
Your data array c contains objects with keys "0" and "1", where the "1" key holds another object with the properties you want to query (idCatQuestion, idSousCatQuestion, designation). To access these nested properties in AlaSQL, you need to adjust your query.
Try this modified version of your query:
In this query,
[1]->idCatQuestionis used to access the idCatQuestion property of the object nested under the "1" key in each element of your array c. This should correctly group your data by idCatQuestion and count the occurrences.