日期:2014-05-19  浏览次数:20526 次

SQL 2000行列式
SQL   2000行列式  
Hi   guys!
我有一个这样的表:
if   exists   (select   1
from   sysobjects
where   id   =   object_id( 'ProProcess ')
and   type   =   'U ')
drop   table   ProProcess
go


/*==============================================================*/
/*   Table:   ProProcess   */
/*==============================================================*/
create   table   ProProcess   (
PROP_ID   bigint   identity,
PROP_JOBNO   varchar(10)   not   null,
PROP_PROCESS_NO   varchar(30)   not   null,
PROP_CLASS_NO   varchar(10)   null,
PROP_MAC_NO   varchar(30)   null,
PROP_STARTDT   datetime   null,
PROP_FINISHDT   datetime   null,
PROP_CREATEDT   datetime   null,
PROP_UPDATEDT   datetime   null,
PROP_CREATER   varchar(30)   null,
constraint   PK_PROPROCESS   primary   key   (PROP_JOBNO,   PROP_PROCESS_NO)
)
go

测试数据如下:
insert   into   ProProcess(PROP_JOBNO,   PROP_PROCESS_NO,   PROP_CLASS_NO,   PROP_MAC_NO,   PROP_STARTDT,   PROP_FINISHDT)
select   'B0001 ',   'Get   Order ',   'D ',   NULL,   '2007-05-02   12:00:00 ', '2007-05-02   12:01:00 '   union
select   'B0001 ',   'Make   Film ',   'D ',   NULL,   '2007-05-02   12:05:00 ', '2007-05-02   12:11:00 '   union
select   'B0001 ',   'Open   Paper ',   'D ',   '01 ',   '2007-05-02   12:12:00 ', '2007-05-02   12:15:00 '   union
select   'B0001 ',   'Printing ',   'D ',   'P02 ',   '2007-05-02   12:17:00 ', '2007-05-02   12:37:00 '   union
select   'B0002 ',   'Get   Order ',   'D ',   NULL,   '2007-05-02   12:00:00 ', '2007-05-02   12:01:00 '   union
select   'B0002 ',   'Make   Film ',   'D ',   NULL,   '2007-05-02   12:05:00 ', '2007-05-02   12:11:00 '   union
select   'B0002 ',   'Open   Paper ',   'D ',   '02 ',   '2007-05-02   12:12:00 ', '2007-05-02   12:15:00 '   union
select   'B0002 ',   'Printing ',   'D ',   'P01 ',   '2007-05-02   12:17:00 ', '2007-05-02   12:37:00 '  
GO

现在需要的结果为:
[PROP_JOBNO],   [Get   Order],   [Get   Order   StartDT],   [Get   Order   EndDT],   [Make   Film],   [Make   Film   StartDT],   [Make   Film   EndDT],   [Open   Paper],   [Open   Paper   StartDT],   [Open   Paper   EndDT],   [Printing],   [Printing   StartDT],   [Printing   EndDT]
B0001,   NULL,   2007-05-02   12:00:00,2007-05-02   12:01:00,NULL,2007-05-02   12:05:00,2007-05-02   12:11:00,01,2007-05-02   12:12:00,2007-05-02   12:15:00,P02,2007-05-02   12:17:00,2007-05-02   12:37:00
B0002,   NULL,   2007-05-02   12:00:00,2007-05-02   12:01:00,NULL,2007-05-02