Backendless Support
 
Answered

error received when using WHERE Clause

app ID: 8FEB9560-F06E-FB42-FF04-1FF206472200

WHERE Clause:

  1. year = 2018 AND month = 5 AND day = 3 AND roomId IN ('EL1411', 'EL1100', 'EL1107', 'EL1110', 'EL1111', 'EL1114', 'EL1145', 'EL1148', 'EL1149', 'EL1150', 'EL1221', 'EL1231', 'EL1261', 'EL1321', 'EL1344', 'EL1345', 'EL1-C05a', 'EL1-C05b', 'EL1-C05c', 'EL1-C06', 'EL1200', 'EL1300', 'EL1123', 'EL1317', 'EL1441', 'EL1470A', 'EL1470B', 'EL1355', 'EL1245', 'EL1270', 'EL1134', 'EL1136', 'EL1138', 'EL1140', 'EL1142', 'EL1144', 'EL1146', 'EL1253', 'EL1348', 'EL1337', 'EL1341', 'EL1310', 'EL1168', 'EL2130', 'EL2150', 'EL2211', 'EL2221', 'EL2249', 'EL2251', 'EL2310', 'EL2321', 'EL2332', 'EL2341', 'EL2346', 'EL2348', 'EL2355', 'EL2451', 'EL2403', 'EL2441', 'EL2-C05', 'EL2-C07', 'EL2-C08', 'EL2-C11', 'EL2317', 'EL2121', 'EL2135', 'EL2145', 'EL2151', 'EL2155', 'EL2252', 'EL2254', 'EL2256', 'EL2258', 'EL2342', 'EL2344', 'EL2441A', 'EL2441B', 'EL2405', 'EL2407', 'EL2411', 'EL2214', 'EL2231', 'EL2245', 'EL2XXX', 'EL2240', 'EL2451A', 'EL2451B', 'EL3110', 'EL3113', 'EL3130', 'EL3150', 'EL3151', 'EL3170', 'EL3171', 'EL3211', 'EL3219', 'EL3239', 'EL3250', 'EL3251', 'EL3254', 'EL3256', 'EL3270', 'EL3271', 'EL3302', 'EL3310', 'EL3320', 'EL3321', 'EL3350', 'EL3-C02', 'EL3317', 'EL3255', 'EL3258', 'EL3353', 'EL3257', 'EL3260', 'EL3355', 'EL3249', 'EL3119', 'AC3-17a', 'AC3-17b', 'AC3-17c', 'AC3-17d', 'EL3100', 'EL4100', 'EL4101', 'EL4113', 'EL4150', 'EL4151', 'EL4171', 'EL4200', 'EL4211', 'EL4251', 'EL4261', 'EL4310', 'EL4321', 'EL4352', 'EL4-C02', 'EL4-C04', 'EL4317', 'EL4330A', 'EL4119', 'AC4-17a', 'AC4-17b', 'AC4-17c', 'AC4-17d', 'EL4201')

private func calculateSumForAllRoomsInADay(_ allRoomsSearchingStr: String){

  1. //var sum = 0

    let queryBuilder = DataQueryBuilder()!

    let year = self.year[pkerview.selectedRow(inComponent: 0)]

    let month = self.month[pkerview.selectedRow(inComponent: 1)]

    let day = self.day[pkerview.selectedRow(inComponent: 2)]

    let whereClause = "year = \(year) AND month = \(month) AND day = \(day) AND roomId IN \(allRoomsSearchingStr)"

    queryBuilder.setWhereClause(whereClause)

    queryBuilder.setProperties(["Count[objectId] as totalObjects", "Sum(numOfPeople) as totalPeople"])

    print(whereClause)

    for i in 8...23 {

    let dataStore = self.backendless.data.ofTable("Record_\(i)")

    dataStore?.find(queryBuilder, response: { (response) in

    print(response)

    }, error: { fault in

    print("Sever reported an error: \(fault!)")

    })

    }

    }

Leave a Comment

Comments (1)

photo
1

The problem is right here:

Count[objectId] as totalObjects

The proper syntax is:

Count(objectId) as totalObjects