要最多两个表列 [英] Want maximum of two table column

查看:69
本文介绍了要最多两个表列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我创建了两个表,分别是indledger和cash_indledger,它们具有两个相同的列,即"entryno".现在,我想要"entryno"的最大值.这两个表中的max(entryno)可以在单个查询中集中起来....
请帮帮我....
谢谢.

Hello,
I have created two tables namely indledger and cash_indledger which has two same column namely "entryno".Now i want the maximum of "entryno" ie. max(entryno) from these two tables collectively in a single query....
Please help me....
Thank you.

推荐答案

使用UNION

Use UNION

SELECT MAX(entryno) AS m FROM tbl1
UNION
SELECT MAX(exitno) AS m FROM tbl2


SELECT CASE WHEN MAX(indledger.entryno) > MAX(cash_indledger.entryno) THEN MAX(indledger.entryno) ELSE MAX(cash_indledger.entryno) END FROM indledger, cash_indledger;


这篇关于要最多两个表列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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