我有两个表,即history和errorlist。 历史记录包含具有详细信息的交易记录。其中之一是错误代码。即错误列表表包含错误代码和描述的列表。现在我想从两个表中选择结果,显示历史记录表中出现不同错误代码的次数以及错误列表表中相同错误代码的相关错误描述。请帮忙。使用oracle从两个表中选择
-3
A
回答
0
假设你想要一个内部联接的两个表:
select errorcode, errordescription, count(*)
from error, history
where history.errorcode = error.code
group by history.errorcode, history.errordescription
编辑:
假设的错误代码是在错误表中是唯一,并使用您所提供的字段名称:
select h.errorcode, count(*) as count
from history h
group by h.errorcode
如果您需要说明,太那么你可能需要包括一个子查询:
select z.errorcode, (select errordesc from error where errorcode = z.errorcode), z.count
from (
select h.errorcode, count(*) as count
from history h
group by h.errorcode
) z
+0
我想也有错误描述为相应的错误代码显示在相同的结果集 – RahulMuk07
+0
它应该像errorcount,errorcode,errordescription – RahulMuk07
+0
那该怎么办? –
相关问题
- 1. Oracle SQL - 从两个表中选择
- 2. Oracle/PLSQL。选择两个表
- 3. 从两个表中选择
- 4. 从两个表中选择?
- 5. 从两个表中选择?
- 6. 从两个表中选择一个表
- 7. ORACLE从3个表中选择
- 8. 从两个表中选择joid vs加入两个选择
- 9. 在Oracle中使用SQL从3个表中选择数据
- 10. 使用LINQ从两个IEnumerables中选择
- 11. 从两个表中选择一个XML
- 12. 从一个两个表中选择值
- 13. 从两个表中选择一个
- 14. 从一个表中选择计数,从另一个列中选择计数ORACLE
- 15. 从两个表中选择,单循环
- 16. 从两个mysql表中选择数据
- 17. 从两个表中选择和计数
- 18. 从两个表中选择字段sql
- 19. 从两个表中选择值
- 20. PostgreSQL从两个表中选择空值
- 21. 从两个表中选择休眠?
- 22. 从两个表中选择列Yii2
- 23. 从两个表中选择sql
- 24. 从两个表中选择数据
- 25. 如何从两个表中选择?
- 26. 同时从两个表中选择?
- 27. 从两个表中选择值mysql
- 28. MYSQL从两个表中选择
- 29. 从这两个表中选择值
- 30. 如何从两个表中选择值
使用Oracle DBMS中 – RahulMuk07
SELECT COUNT(*)作为ERROR_COUNT,c.errorno,e.errordesc从HIST℃的内部通过c.errorno – RahulMuk07
加入errorlist EON c.errorno = e.errorcode组,但这并不工作 – RahulMuk07