我在用delphi和sql server开发客户信息管理系统,现在要对客户进行细分,购买额排序前1%为大客户,4%为重要客户,15%为一般客户,80%为小客户。
我对sell表用order by查询出了销售排行,我想请教各位大侠们如何实现这么一个细分过程。
客户ID 销售总金额 排序,我是打算在查询上添加一个排序字段,然后通过公式得出细分结果,但我不知道具体怎么做,我是个新手,各位大侠大家帮帮忙
我对sell表用order by查询出了销售排行,我想请教各位大侠们如何实现这么一个细分过程。
客户ID 销售总金额 排序,我是打算在查询上添加一个排序字段,然后通过公式得出细分结果,但我不知道具体怎么做,我是个新手,各位大侠大家帮帮忙
2、对于数值的排序,使用DELPHI语句排序较好。如读入数组使用冒泡排序.....
set ftype='大客户'
where id in (
select top 1 percent
id
from sell表
order by 销售额
)update sell表
set ftype='重要客户'
where id not in (
select top 1 percent
id
from sell表
order by 销售额
)
and id in (
select top 5 percent
id
from sell表
order by 销售额
)...
order by 销售额 desc
set @Count = (select count(*) from 表)
select RowId as 客户销售排序,客户ID ,销售总金额, 排序,
case when Rowid <= @Count / 100 then '大客户'
when Rowid > @Count * 4 / 100 and Rowid <= @Count * 15 / 100 then '重要客户'
when Rowid > @Count * 15 / 100 and Rowid <= @Count * 80 / 100 then '一般客户'
when Rowid > @Count * 80 / 100 then '小客户'
end 用户 from
(
SELECT RowId = ROW_NUMBER() OVER (ORDER BY 销售总金额 desc),客户ID 销售总金额 排序
FROM 表
) as mytable