select sum(total) from (
(select sum(team1_score) as total from country,match_results where country_name=team1 group by country_name as s1)
UNION ALL
(select sum(team2_score) as total from country,match_results where country_name=team2 group by country_name as s2)
);
Q
不能通过
1
A
回答
0
从
select sum(total) from (
select sum(team1_score) as total
from country,match_results
where country_name=team1
group by country_name
UNION ALL
select sum(team2_score)
from country,match_results
where country_name=team2
group by country_name
) T
删除在选择第二别名和别名为组和assigna真名的子查询,您应该使用显式的内部连接
select sum(total) from (
select sum(team1_score) as total
from country
inner join match_results on country.country_name=team1 and
match_results.team1=team1
group by country_name
UNION ALL
select sum(team2_score)
from country
inner join match_results on country.country_name=team2 and
match_results.team2=team2
group by country_name
) T
1
尝试移除即别名as s1
和as s2
+0
试过没有工作,我还是谢谢你 –
0
别名应是子查询外,使用组中的SQL两个查询的结合; MySQL可能认为你试图(毫无意义地)混淆了分组标准。
+0
尝试没有工作,无论如何谢谢 –
相关问题
- 1. 不能通过intent.putExtra
- 2. 不能通过AJAX
- 3. 不能通过Corelocation
- 4. 不能通过ID
- 5. 通过不同的功能
- 6. 不能通过在dispatcher.invoke
- 7. 不能通过测试seed.db
- 8. 不能产生通过PHP
- 9. 通过引用不可能?
- 10. 不能与通过API V4
- 11. 爪哇不能通过JSON.stringfy
- 12. 不能通过子类
- 13. 不能通过socket.io发出?
- 14. 不能够通过代码
- 15. 不能通过uri段
- 16. 不能通过$头变量()
- 17. LinkedBlockQueue不能通过必看
- 18. 不能(通过卷曲)
- 19. IN pq.Array不能通过值
- 20. 只能通过通过ssh
- 21. 不能通过日将存储过程
- 22. 不能通过功能指令
- 23. 不能通过getNodeValue功能在常规
- 24. 通过功能
- 25. 通过FTP创建的文件不能通过FTP删除
- 26. 不能通过任何变量通过jquery ajax
- 27. 可以通过shell连接到mongodb,但不能通过mongoid
- 28. 只能通过id找到,而不能通过班级找到BeautidulSoup4(Python3.x)
- 29. 只能通过本地主机连接而不能通过IP连接
- 30. 只能通过WCF实现但不能通过Web API实现的方案
非常感谢scaisEdge,两种解决方案现在工作得很好。但在第二个建议使用内部连接,你可以解释为什么使用两个条件 country.country_name = team2和match_results.team2 = team2? –
是相同的..我hav eopted这个,因为更容易理解,但你也可以使用国家内部联接match_results country.country_name = match_results.country_name和country.country_name = team1 ...是一样的...使用传递属性或不结果不改变 – scaisEdge
@nikhilkekan好,如果我的回答是正确的请标记为接受...看到这里如何 http://meta.stackexchange.com/questions/5234/how-does -accepting-的回答工作 – scaisEdge