作业帮 > 综合 > 作业

列名acct_month ,acct_year,表名acct_vouch查询最大、小月,最小月要对应最小年

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/05/05 19:37:49
列名acct_month ,acct_year,表名acct_vouch查询最大、小月,最小月要对应最小年
select min(acct_month) as start_month from acct_vouch where acct_year=(select min(acct_year) from acct_vouch)
select max(acct_month) as cur_month from acct_vouch where acct_year=(select max(acct_year) from acct_vouch)
select max(acct_year)as cur_year,min(acct_year)as start_year from acct_vouch 我只会分3句写 求高手一句sql查询 最大最小月
列名acct_month ,acct_year,表名acct_vouch查询最大、小月,最小月要对应最小年
拿去直接可以用
select t.cur_year as 最大年份,t.start_year as 最小年份,t.am as 最大月份,x.xm as 最小月份 from (select max(acct_year)as cur_year,min(acct_year)as start_year,MAX(acct_month) as am from acct_vouch) t ,(select min(acct_year)as cur_year,min(acct_year)as start_year,min(acct_month) as xm from acct_vouch) x
再问: 要求要一句sql写出来 在vs2010里面写的话 太多句不方便
再答: 这就是一句SQL呀,你自己拿到SQL里面跑一下就知道了,而且VS2010里面这样的SQL不算长,放心使用,本人写过最长的SQL有30行的,你这点不算什么。