开发者

Select MIN and MAX dates between two columns from different tables

I h开发者_如何学运维ave expenseDate (table A) and invoicedate (table B). There is no relation between those tables.

I need to get MIN and MAX dates between expenseDate and invoiceDate.

Since I'm not familiar with backend, could someone help? Thanks.


SELECT MIN(mydate) mindate, MAX(mydate) maxdate
FROM(
SELECT expenseDate AS mydate
FROM tableA
UNION ALL
SELECT invoicedate AS mydate
FROM tableB
) AS table


select min(datedata), max(datedata) from (
    select expensedate datedata from table A
    union all
    select invoicedate datedata from table B )

If this is what you want...

HTH


Initial thought is select MIN(expenseDate) and MIN(invoiceDate), and then return the lowest of those. Similarly with the highest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜