如何从PostgreSQL中的两个列中获取具有最大值的记录
我在postgressql中的表结构如下 则一个TicketID可以具有多个优先级和评级
如果我想要所有具有最高优先级为2和最大评分为3的机票ID的列表, 。 则输出应给出T2和T4。
然后,如果我想要所有具有最大优先级为3和最大额定值为3的机票ID的列表, 然后输出应给出T1,只有
我不确定如何编写此
I have table structure like below in postgressql
Where one ticketid can have multiple priority and rating
If i want the list of all ticket ids who have max priority as 2 and max rating as 3.
Then output should give t2 and t4
If i want the list of all ticket ids who have max priority as 3 and max rating as 3.
Then output should give t1 only
I am not sure how to write a query for this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
具有
关键字来分组后过滤汇总:You can use the
HAVING
keyword to filter an aggregate after grouping: