如何编写查询来计算表中特定列的所有字段数据?我一直在尝试这个过去5个小时但没有成功。
请帮帮我。提前谢谢。
答案 0 :(得分:0)
如果您只想要特定值的计数
,请使用此选项SELECT COUNT(*) FROM table_name WHERE column_name = 'your_value'
如果您希望列中的所有不同值及其各自的计数,请使用此
SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name
答案 1 :(得分:0)
使用-(void)postOnLinkedIn:(NSMutableDictionary *)dictData {
NSMutableDictionary *dictCode = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"anyone",@"code", nil];
[dictData setObject:@"Check out developer.linkedin.com! http://linkd.in/1FC2PyG" forKey:@"comment"];
[dictData setObject:dictCode forKey:@"visibility"];
NSString *url = @"https://api.linkedin.com/v1/people/~/shares";
NSString *payload = [NSString stringWithFormat:@"%@",dictData];
NSLog(@"%@",payload);
// NSString *payload = [NSString initWithString:@"{
// \"comment\":\"Check out developer.linkedin.com! http://linkd.in/1FC2PyG\",
// \"visibility\":{ \"code\":\"anyone\" }
// }"];
if ([LISDKSessionManager hasValidSession]) {
[[LISDKAPIHelper sharedInstance] postRequest:url stringBody:payload
success:^(LISDKAPIResponse *response) {
// do something with response
}
error:^(LISDKAPIError *apiError) {
// do something with error
}];
}
else {
[self connectToLinkedIn];
}
}
-(void)connectToLinkedIn {
[LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION,LISDK_EMAILADDRESS_PERMISSION,LISDK_W_SHARE_PERMISSION, nil]
state:@"state"
showGoToAppStoreDialog:YES
successBlock:^(NSString *returnState) {
NSLog(@"%s","success called!");
LISDKSession *session = [[LISDKSessionManager sharedInstance] session];
NSLog(@"value=%@ isvalid=%@",[session value],[session isValid] ? @"YES" : @"NO");
}
errorBlock:^(NSError *error) {
//[self clearSession:<#(id)#>]
NSLog(@"%s %@","error called! ", [error description]);
//self.lastError = error;
// _responseLabel.text = [error description];
//[self updateControlsWithResponseLabel:YES];
}
];
}
和COUNT
。
<强>查询强>
GROUP BY