create procedure test
as declare my_cursor cursor local --scroll表示可隨意移動游標指標(否則只能向前),dynamic表示可以讀寫游標(否則游標唯讀)
forselect workerid,count(1) tep from worker group by workerid
order by count(1)
open my_cursor-----全部客戶**號碼
declare @workerid sysname
declare @mycount int
declare @count int
declare @more int
declare @sql varchar(2000)
set @count=(select count(*) from powercustomer)/(select count(distinct workerid) from worker)
set @more=(select count(*) from powercustomer)%(select count(distinct workerid) from worker)
begin
truncate table temptable
insert into temptable(phonenum) select distinct phonenum from powercustomer where phonenum not in (select distinct phonenum from worker)
endbegin
fetch next from my_cursor into @workerid,@mycount
while(@@fetch_status=0)
begin
if @more>1
begin
set @sql='update temptable set workerid='+@workerid+' where phonenum in (select top '+convert(varchar,(@count-@mycount+1))+' phonenum from temptable where workerid is null)'
set @more=@more-1
endelse if @more=0
begin
set @sql='update temptable set workerid='+@workerid+' where phonenum in (select top '+convert(varchar,@count-@mycount)+' phonenum from temptable where workerid is null)'
endexec(@sql)
--commit
fetch next from my_cursor into @workerid,@mycount
endclose my_cursor
end
mysql 查詢多列不重複的資料
語法 select distinct 列名稱 from 表名稱 如果要查詢某列完全不同的值,可以這樣用distinct。如果是多列呢?這時只用distinct明顯不能實現。比如 要查詢firstname和address完全不同的資料 想要查詢如下結果的資料 使用多列分組查詢則可以實現該查詢要求 se...
pentaho cde 選擇性的顯示多列資料
在業務需求中,有時候會有這種需要,就是查出來可多列資料,而我只想畫出來其中的一列或者說某一列,而pentaho會預設畫出查出來的所有資料,而不斷的更改資料來源又太麻煩,這時就要用到resders方法了。比如這裡我只想顯示一列資料 ismultivalued 和 datameasuresincolum...
求助,awk如何根據多列去除重複的記錄
例子如下 0052850101003,20,285,410010001 0052850101003,20,281,410010001 0052850101003,22,280,410010001 0052850101003,21,20,410010001 0052850101003,21,28,41...