select * from tab where ioid+accname in (select max(ioid)+accname from tab)
select accnam,max(ioid) from table group by accname
select * from tab where ioid+accname in (select max(ioid)+accname from tab group by accname)
select ioid top1 from table group by accname order by ioid desc
select max(ioid) as ioid,accname from table group by accname
希希的: 列 'tb_acc_io.io_id' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。 alexwoowf(吴) 的: 将 varchar 值 'epson ' 转换为数据类型为 int 的列时发生语法错误。 《ioid 是int 类型的,accname是char类型的》 怎么解决呢? 谢谢
难道这个都不好使吗?? select max(ioid) as ioid,accname from table group by accname
leimin 的 :如过还要选择其他列如io_accnum的话,也报列 'tb_acc_io.io_outnum' 在选择列表中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
yoki(小马哥) :这个就不能选择其他字段。和我楼上的回复一样 该怎样呢?
you should do it as follows: select ioid, accname, io_accnum from tb_acc_io where ioid in (select max(ioid) from tb_acc_io group by accname) order by ioid
up is right!or you can try below: select a.ioid,a.accname,a.io_accnum from tb_acc_io as a right outer join (select max(ioid) as ioid1 from tb_acc_io group by accname)b on a.ioid=b.ioid1
group by accname
group by accname
order by ioid desc
group by accname
怎么解决呢?
谢谢
select max(ioid) as ioid,accname from table
group by accname
该怎样呢?
select ioid, accname, io_accnum from tb_acc_io where ioid in
(select max(ioid) from tb_acc_io group by accname) order by ioid
select a.ioid,a.accname,a.io_accnum from tb_acc_io as a
right outer join
(select max(ioid) as ioid1 from tb_acc_io group by accname)b
on a.ioid=b.ioid1