我想知道是否有办法让这项工作成功。我正在推导一个表“WHERE lie_start ='green'”(以及一些我不想重复的其他条件),需要从中获取数字(以及其他一些信息)。 另外,我需要附加条件为lie_finish ='holed'的条目数。目前我得到错误:表mydb.x不存在。
private IntentFilter intentFilter;
static {
intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_TIME_TICK);
intentFilter.addAction(Intent.ACTION_UNINSTALL_PACKAGE);
}
private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(Intent.ACTION_UNINSTALL_PACKAGE) {
Log.e("App", "Uninstalling");
} else if (action.equals(Intent.ACTION_TIME_TICK){
// this works
}
}
};
答案 0 :(得分:1)
您需要重复表名。表别名无法识别:
SELECT COUNT(*) AS total,
(SELECT COUNT(*) FROM mydb.strokes WHERE lie_finish='holed') as holed
FROM (SELECT * FROM mydb.strokes WHERE lie_start='green') as x;
然而,这更简单地写为:
select count(*) as total, sum(lie_finish = 'holed') as holed
from mydb.strokes s
where lie_start = 'green';