似乎我还不够清楚。 似乎有效的查询是:
Select ((Select count (table1.id) from table1 where table1.code=2 and table1.name=5) as ‘name5’,
(Select count (table1.id) from table1 where table1.code=2 and table1.name=7) as ‘name7’)
From table.1;
union
Select ((Select count (table1.id) from table1 where table1.code=5 and table1.name=5) as ‘name5’,
(Select count (table1.id) from table1 where table1.code=5 and table1.name=7) as ‘name7’)
From table.1;
union
Select ((Select count (table1.id) from table1 where table1.code=15 and table1.name=5) as ‘name5’,
(Select count (table1.id) from table1 where table1.code=15 and table1.name=7) as ‘name7’)
From table.1;
...
得到这样的结果:
name5 name7
52 47
42 84
61 11
我的问题是table1.code除了2,5和15之外还有一千个以上的值,我不能重复一次这样的联合语句。
答案 0 :(得分:1)
好吧,您似乎只想按代码列中的值进行分组,并且可以使用IN或EXISTS
export class SecureComponent implements OnInit {
userRole:any;
role:string = 'MEMBER';
constructor(private userService: UserService,private router:Router) {
}
ngOnInit() {
this.role = 'MEMBER';
console.log('Role',this.userRole);
if (!this.userService.isLoggedIn()) {
this.router.navigateByUrl('/login');
}
}
}
输出将是
select count(table1.id) as theCount, table1.code as theCode
from table1 where table1.code in ('code a','code b', 'etc...')
group by table1.code;
或类似的东西,但非计数的非名义数字 HTH
答案 1 :(得分:0)
您可以尝试列出嵌套选择列表中从a到您的值的所有值,例如: 100,就像那样:
select count table1.id from table1 one where table1.code in (
select rownum from all_objects where rownum < 100
);
或者如果你不想从“1”开始:
select count table1.id from table1 one where table1.code in (
select rownum n from dual connect by level 10 where n>3
);