--为GoodName列建立全文索引数据元,PK_EC_Goods为ec_goods表中由主键所建立的唯一索引,这个参数是必需的。
execute sp_fulltext_table 'ec_goods','create','GoodsSearch','PK_EC_Goods'
--设置全文索引列名
execute sp_fulltext_column 'ec_goods','goodname','add'
--建立全文索引
--activate,是激活表的全文检索能力,也就是在全文目录中注册该表
execute sp_fulltext_table 'ec_goods','activate'
--填充全文索引目录
execute sp_fulltext_catalog 'GoodsSearch','start_full'
--查询全文索引是否建立完毕(0:完毕;1:正在建立)
select fulltextcatalogproperty('GoodsSearch','populateStatus')
execute sp_fulltext_table ‘book’,‘create’, ‘ft_test’,‘pk_title’
//设置全文索引列名
execute sp_fulltext_column ‘book’, ‘title’, ‘add’
execute sp_fulltext_column ‘book’,‘notes’, ‘add’
//建立全文索引
execute sp_fulltext_table ‘book’, ‘activate’
//填充全文索引目录
execute sp_fulltext_catalog ‘ft_test’, ‘start_full’
至此,全文索引建立完毕。
update ec_soitem set ordertime=b.ordertime from ec_soitem a join EC_SalesOrder b
on (a.SOID=b.SOID)
select a.PayableValue,a.Rownumber,EC_Goods.GoodCode,EC_Goods.GoodName,
0.00 as Rate
from EC_Goods
inner join (
select EC_SOItem.GoodID,SUM(EC_SOItem.PayableValue) PayableValue,
ROW_NUMBER() over(order by SUM(EC_SOItem.PayableValue) desc) as Rownumber
from EC_SOItem where OrderTime>='2016-11-01'and OrderTime<'2016-12-01'
group by EC_SOItem.GoodID) a on a.GoodID=EC_Goods.GoodID
where Rownumber<=10
go--我记得优化这个的时候,是修改了表结构 把 ec_salesorder表里面的一些字段转移到ec_soitem,为了不要进行表连接,(因为两个表的数据量都是千万级的)