如何在oracle中编写查询 [英] How to write a query in oracle

查看:125
本文介绍了如何在oracle中编写查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

序号码状态号码

1 321待定LK123

2 321待定LK123

3 321已完成LK123

4 456待定LK234

5 456已完成LK456



如果在单个数字上更改状态,那么我只想显示xyz和状态在不同的Nums上更改我想要显示所有



如下所示

Id状态号

321已完成LK123

456待定LK234

456已完成LK456



tq。



我尝试了什么:



i显示全部(abc,xyz)

seq Id Status Num
1 321 Pending LK123
2 321 Pending LK123
3 321 Completed LK123
4 456 Pending LK234
5 456 Completed LK456

if status is changed on single num then i want to show only xyz and if status is changed on different Nums the i want to show all

like below
Id Status Num
321 Completed LK123
456 Pending LK234
456 Completed LK456

tq.

What I have tried:

i have showing all (abc , xyz)

推荐答案

请参阅此处: Oracle / PLSQL:GROUP BY子句 [ ^ ]用它来汇集所有相关的行,并返回每个组的MAX Seq值。

然后,您可以使用JOIN仅获取与该Seq值匹配的行。
See here: Oracle / PLSQL: GROUP BY Clause[^] Use that to gather together all related rows, and to return the MAX Seq value for each group.
You can then use JOIN to fetch only the rows that match that Seq value.


这篇关于如何在oracle中编写查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆