SQL retrospect

http://www.1keydata.com/sql/sql-rank.html

create trigger tg_name on master_table for delete
as
    declare @fact varchar(100);  
    select @fact = factory from hbiao;
    delete from hbiaowc where factory =@fact;


create procedure Delete
(@d varchar(40),
 @d2 int
)
as
(
declare @b varchar(10);
delete from ;
delete from ;
)

Calculate Rank
SELECT a1.Name, a1.Sales, COUNT(a2.sales) Sales_Rank
FROM Total_Sales a1, Total_Sales a2
WHERE a1.Sales < a2.Sales or (a1.Sales=a2.Sales and a1.Name = a2.Name)
GROUP BY a1.Name, a1.Sales
ORDER BY a1.Sales DESC, a1.Name DESC;

 

select '31-已支付'as a1 ,trim(voucheracct) as a2 ,'11-一般预算' as a3,trim(basiccode) ||'-'|| trim(basicname) as a4,'' as a5 ,trim(use) as a6 ,payamount as a7,'1-直接支付' as a8,trim(expfunccode) || '-' || trim(expfuncname) as a9,'' as a10,'2-转帐' as a11, trim(payername) as a12,trim(payerbankname) as a13,trim(payeracct) as a14,trim(payeename) as a15, trim(payeebankname) as a16,trim(payeeacct) as a17,case when qrjg='15605' then '金家庄区' when qrjg='15606' then '雨山区' when qrjg='15600' then '花山' else '' end as a18,'900001-支行' as a19,'支行' as a20,case when qrjg='15605' then '27104' when qrjg='15606' then '27105' when qrjg='15600' then '27107' else '' end as a21,trim(qrgy) as a22,trim(maketickdate) as a23 from ts_czzf_zjzfpz t where qrbz='0' and status='0' and jsrq='20120604' and qrjg='15606'

posted @ 2012-04-19 13:32  Further  阅读(3505)  评论(0编辑  收藏  举报