企业数据统计分析工作

原创 2011年01月24日 10:30:00

企业数据统计分析工作


declare @tab1 table(ID int,
                    单号 varchar(20),
                    提货日期 datetime,
                    实发数量 decimal(8,1),
                    累计 decimal(8,1))
declare @ID int
declare @提货日期 varchar(20)
declare @实发数量 decimal(8,1)
declare @累计 decimal(8,1)

set @累计=0
declare Num_Cursor CURSOR FOR
 select * from @tab

open Num_Cursor
fetch next from Num_Cursor into @ID,@单号,@提货日期,@实发数量
wile @@FETCH_STATUS=0
begin
 set @累计=@累计+@实发数量
 insert @tab1
 values(@ID,@单号,@提货日期,@实发数量,@累计)
 fetch next from Num_Cursor into @ID,@单号,@提货日期
end

close Num_Cursor

deallocate Num_Cursr

 

 


declare Num_Cursor CURSOR FOR
select * from @tab

open Num_Cursor
fetch next from Num_Cursor into @ID,@单号,@提货日期,@实发数量
while @@FETCH_STATUS=0
begin
 set @累计=@累计+@实发数量
 insert @tab1
 values (@ID,@单号,@提货日期,@实发数量,@累计)
 fetch next from Num_Cursor into @ID,@单号,@提货日期,@实发数量
end

close Num_Cursor
deallocate Num_Cursor

select * from @tab1

 


identity identity

 

select 日期,店铺名,销售量
from DezaiCn_Sale
group by 日期,店铺名,销售量
order by 店铺名

 


select 店铺名,SUM(销售量) as 总销售量
from DezaiCn_Sale
where (店铺名='A') and (日期 between '2008-1-1' and '2008-9-1')
group by 店铺名

 


select SUM(销售量) as 销售总量,日期
from DezaiCn_Sale
where (日期='2008-3-1')
group by 日期

 

 

Create procedure DezaiCnTestSale_SalerCompareSaleByDate /*代理销售产品比较*/
@ProductIDArray varchar(1000),/*产品ID组*/
@begindate datetime,/*比较开始日期*/
@endDate datetime,/*比较结束时间*/
@shop varchar(20)/*店铺名*/

as
 declare @sql varchar(8000)
 set @sql='select 产品ID'

 select @sql=@sql+',max(case Convert(varchar(10),日期,120) when ''''+Convert(varchar(10),日期,120)+'''' then 销售量 else 0 end)['+Convert(varchar(10),日期,120)+']'

from (select distinct 日期 from DezaiCn_Sale where 日期 between @begindate and @endDate) as a


set @sql=@sql+' from DezaiCn_Sale where 产品ID in ('+@ProductIDArray+') and 店铺名=''''+@shop+''''
group by 产品Id'

exec(@sql)
go

select name,sum(score) as ZCJ
 from stuscore
group by name
order by zcj

 

select distinct t1.name,t1.stuid,t2.allscore
from stuscore t1,
     (
      select stuid,sum(score) as allscore
       from stuscore
      group by stuid
      ) t2
where t1.stuid=t2.stuid
order by t2.allscore desc


select t1.stuid,t1.name,t1.subject,t1.score
 from stuscore t1,
      (
       select stuid,max(score) as maxscore
        from stuscore
        group by stuid
      ) t2
where t1.stuid=t2.stuid
      and t1.score=t2.maxscore

 


select distinct t1.stuid,t1.name,t2.avgscore
 from stuscore t1,
      (
       select stuid,avg(score) as avgscore
        from stuscore
        group by stuid
      ) t2
where t1.stuid=t2.stuid
     


select t1.stuid,t1.name,t1.subject,t2.maxscore
 from stuscore t1,
      (
       select subject,max(score) as maxscore
        from stuscore
       group by subject
      ) t2
where t1.subject=t2.subject
      and t1.score=t2.maxscore

 

select distinct t1.*
 from stuscore t1
 where t1.id in(
                select top 2 stuscore.id
                  from stuscore
                 where subject=t1.subject
                 order by score desc
                )
order by t1.subject

 

select stuid as 学号,
       name as 姓名,
       sum(case when subject='语文' then score else 0 end) as'语文',
       sum(case when subject='数学' then score else 0 end) as'数学',
       sum(case when subject='英语' then score else 0 end) as'英语',
       sum(score) as 总分,
       (sum(score)/count(*))as 平均分
 from  stuscore
 group by stuid,name
 order by 总分 desc


select subject,avg(score) as avgscore
 from stuscore
 group by subject


declare @tmp table(pm int,name varchar(50),score int,stuid int)
insert into @tmp
        select null,name,score,stuid
          from stuscore
         where subject='数学'
         order by  score desc
declare @id int
  set @id=0;
update @tmp set @id=@id+1,
                pm=@id
select * form @tmp where name='李四'

 

selecdt subject,
        (select count(*) from stuscore where score<60 and subject=t1.subject) as 不及格,
        (select count(*) from stuscore where score between 60 and 80 and subject=t1.subject) as 良,
        (select count(*) from stuscore where score>80 and subject=t1.subject) as 优秀
from stuscore t1
group subject

 

declare @s varchar(1000)
set @s=''
select @s=@s+','+name+'('+convert(varchar(10),score)+'分)'
 from sutuscore
 where subject='数学'
set @s=stuff(@s,1,1,'')
print'数学:'+@s

 


select a.Description,
       Record_Count=Count(b.ID),
       [Percent]=case
                    when Counts=0 then '0.00%'
                    else cast(cast(count(b.ID)*100./c.counts as decimal(10,2)) as varchar)+'%'
                  end
from(
     select sid=1,a=Null,b=30,Description='<30'
     union all
     select sid=2,a=30,b=60,Description='>30 and <60'
     union all
     select sid=3,a=60,b=75,Description='>=60 and <75
    ) a Left join @t b
             on(b.col<a.b or a.b is null)
                and(b.col>=a.a or a.a is null)
            cross join(select counts=count(*) from @t)c
group by a.Description,a.sid,c.counts
order by a.sid

 


with Form2 do
begin
  for i:=0 to ComponentCount-1 do
     if(Components[i] is TCustomEdit) then
        TCustomEdit(Components[i]).text:=IntToStr(i);
end

 


procedure TForm2.btnClick(Sender:TObject);
var
  sformat:string;
  i,iSum:Integer;
  ObjArray:array of Integer;
  arrayCount:Integer;
  temp:string;
begin
  arrayCount:=0;
  temp:='';
  iSum:=0;

  sformat:=Trim(edt1.Text);
  for i:=1 to Length(sformat) do
  begin
    if sformat[i] in ['0'..'9'] then
    begin
       temp:=temp+sformat[i];
       if(i=Length(sformat)) then
       begin
         Inc(arrayCount);

         SetLength(ObjArray,arrayCount);
         ObjArray[arrayCount-1]:=StrToInt(temp);
       end;
    end else
    begin
      if temp<>'' then
      begin
         Inc(arrayCount);
         SetLength(ObjArray,arrayCount);
         ObjArray[arrayCount-1]:=StrToInt(temp);
         temp:='';
      end;
    end;
  end;
 
  for i:=0 to High(ObjArray) do
  begin
    edt2.text:=edt2.text+'+'+IntToStr(ObjArray[i]);
    Inc(iSum,ObjArray[i]);
  end;

  edt2.text:=RightStr(edt2.Text,(Lenght(edt2.text)-1))+'='+IntToStr(iSum);
end;

 

企业数据统计分析工作

企业数据统计分析工作 declare @tab1 table(ID int,                     单号 varchar(20),                     ...

利用大数据玩转移动统计分析市场的方式不止一种,看看TalkingData是怎么做的?

http://www.pingwest.com/demo/talkingdata/ 从2011年起,移动互联网开始进入红海竞争,融资环境差,同质化严重等因素导致应用间的竞争异常惨烈,不过这种状况...

地统计分析笔记——探索数据

在执行地统计分析之前,浏览、熟悉、检查自己的数据是至关重要的。绘制和检查数据是地统计分析过程中的必要阶段,我们可以从这些工作中获得一些先验知识,指导后续的工作。Stage 1 绘制数据通过Ar...

机器学习、统计分析、数据挖掘、神经网络、人工智能、模式识别,

很难说谁包含于谁,只能分开说每一个概念的意义,谁服务于谁。 数据挖掘是一种概念,从数据中挖掘到有意义的信息。 很多人认为数据挖掘是新学科,是基于大数据,其实不然,如果给你一个数据说李嘉诚有10...

Excel VBA自动对故障数据统计分析

Option Explicit Private Sub MyFirstSubRoutine() Dim bOpen As Boolean bOpen = MsgBox("Hello World!...

appstore软件销售数据统计分析软件Prismo

appstore自带的有数据统计分析,但那个太初级了,今天给各位ios/mac开发者推荐一款对appstore apps销售数据做统计分析的软件Prismo,闲话少说,直接上图 1.键入你的apple...
  • xyzs996
  • xyzs996
  • 2013年09月08日 00:25
  • 965

数据统计分析时常用sql语句 (split , row_number , group by, max 等 )

数据统计分析时常用sql语句 (split , row_number , group by, max 等 )

R语言为Hadoop集群数据统计分析带来革命性变化

R作为开源的数据统计分析语言正潜移默化的在企业中扩大自己的影响力。特有的扩展插件可提供免费扩展,并且允许R语言引擎运行在Hadoop集群之上。 R语言是主要用于统计分析、绘图的语言和...

【数据架构解读】基于阿里云数加StreamCompute和MaxCompute构建的访问日志统计分析

【场景】 用户搭建网站会不断的产生访问日志(Nginx,Apache访问日志)。为了从访问日志中挖掘出更多价值,本文主要阐述如果利用阿里云数加从沉睡中的访问日志中获取更有价值的数据,包括用于实时统计和...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:企业数据统计分析工作
举报原因:
原因补充:

(最多只允许输入30个字)