a表里数据如下: 名称 型号 数量
光驱 52x 2
光驱 42x 2
鼠标 光电 2
光驱 42x 2
我用select distinct 名称,型号 from a 查询出:
名称 型号
光驱 48x
光驱 52x
鼠标 光电
但我怎么才能知道用select distinct 名称,型号 from a得出3条记录。
光驱 52x 2
光驱 42x 2
鼠标 光电 2
光驱 42x 2
我用select distinct 名称,型号 from a 查询出:
名称 型号
光驱 48x
光驱 52x
鼠标 光电
但我怎么才能知道用select distinct 名称,型号 from a得出3条记录。
返回受上一语句影响的行数。
(select distinct 名称,型号 from a)a
select distinct 名称,型号,数量 from TB如果数量不相同(使用min或max)
select a.* from TB a ,
(select 名称,型号,min(数量) as 数量 from TB group by 名称,型号) b
where a.名称=b.名称 and a.型号=b.型号 and a.数量=b.数量