如何在单个查询中获得最大值和最小值? [英] How can I get maximum and minimum values in a single query?

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

问题描述

我正在使用 MySQL,我正在寻找一种方法来从两列(例如,posx)获取全局最大值和最小值(对于整个表)posy),只使用一个查询.

I'm using MySQL, and I'm looking for a way to get the global maximum and minimum values (for the whole table) from two columns (for example, posx and posy), using only one query.

推荐答案

简单:

SELECT MIN(posx), MIN(posy), MAX(posx), MAX(posy) FROM table

这篇关于如何在单个查询中获得最大值和最小值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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