select distinct from ( SELECT TOP 300 invoiceNo from table ) A
select distinct * from ( SELECT TOP 300 invoiceNo from table ) A
SELECT DISTINCT TOP 300 invoiceNo from [table]
SELECT DISTINCT TOP 300 invoiceNo from table1
我觉得 aw511(点点星灯) 的方法比较好(除了一点小的笔误(改为select top 300 invoiceNo from (select distinct * from tablename) a)。Hopewell_Go的方法,有点问题. 如果原表中有600条记录。其中,前300条记录都是相同的话, 那么按Hopewell_Go的方法,则只能选出1条记录, 而按‘点点星灯’的方法则可以选出300条记录。 而且我想一般来言,‘点点星灯’的方法更接近需求。SELECT DISTINCT TOP 300 invoiceNo from [table],这种方法可能最接近要求。但是效率可能会比较低。个人看法,不当之处,请斧正。
SELECT DISTINCT TOP 300 (invoiceNo) from table
SELECT DISTINCT TOP 300 invoiceNo from [table] 就行了或 select top 300 invoiceNo from (select distinct * from tablename) a
敢问"select distinct * from tablename"是什么意思?
select top 300 * from (select distinct invoiceNo from tablename) a还有: SELECT DISTINCT TOP 300 invoiceNo from [table],我认为效率很高,也符合需求.
--用 select top 300 * from (select distinct invoiceNo from tablename) a 或 SELECT DISTINCT TOP 300 invoiceNo from [table]--在查询分析器中分析两者的执行效率是一样的
select top 300 * from (select distinct invoiceNo from tablename) a請教 上名中加“a”是什麼意思?
from
(
SELECT TOP 300 invoiceNo
from table
) A
from
(
SELECT TOP 300 invoiceNo
from table
) A
如果原表中有600条记录。其中,前300条记录都是相同的话, 那么按Hopewell_Go的方法,则只能选出1条记录, 而按‘点点星灯’的方法则可以选出300条记录。
而且我想一般来言,‘点点星灯’的方法更接近需求。SELECT DISTINCT TOP 300 invoiceNo from [table],这种方法可能最接近要求。但是效率可能会比较低。个人看法,不当之处,请斧正。
from table
select top 300 invoiceNo from (select distinct * from tablename) a
SELECT DISTINCT TOP 300 invoiceNo from [table],我认为效率很高,也符合需求.
select top 300 * from (select distinct invoiceNo from tablename) a
或
SELECT DISTINCT TOP 300 invoiceNo from [table]--在查询分析器中分析两者的执行效率是一样的