问题
For example, I would like something similar to:
select SUM[likes] from [MyAzureSQLService].[InstagramPost] where user == 'rain'
Here, the "likes" is unsigned integer column in azure sql table "[MyAzureSQLService].[InstagramPost]", I wanted to query the sum number of all likes received by a specific user.
My Swift code in iOS is like this:
guard let table = client.table(withName: tableName) else { return }
guard let query = MSQuery(table: table) else { return }
query.predicate = NSPredicate(format: "user == 'rain'")
query.selectFields = ["SUM(likes)"]
But this didn't work, any ideas?
Thanks!
来源:https://stackoverflow.com/questions/62380694/ios-swift-how-to-perform-sql-sum-function-using-msquery-and-nspredicate