花了半天写出来的个sql语句,分享下
Declare @T Table(
CFF_Loanno nvarchar(100),
BANK_Name_2 nvarchar(100),
CFF_code nvarchar(100),
CFF_date datetime,
CFF_amt decimal(18, 6),
CFF_repay_date datetime,
COMP_Name_2 nvarchar(100)
)
---临时表,存放基础数据
insert into @T(CFF_Loanno ,
BANK_Name_2 ,
CFF_code,
CFF_date,
CFF_amt,
CFF_repay_date,
COMP_Name_2)
SELECT A.CFF_Loanno,B.BANK_Name_2,A.CFF_code,A.CFF_date,A.CFF_amt,A.CFF_repay_date,C.COMP_Name_2
from cashflow_financing as A
inner join Bank as B on
A.CFF_Bank = B.BANK_Code
inner join Company as C on
A.CFF_repay_company = C.COMP_Code
---小计表,按照还款日期汇总
select N'B' as ord,N'小计' as class,
CFF_Loanno as CFF_Loanno ,
CONVERT(varchar(100), CFF_repay_date, 23) as BANK_Name_2 ,
NULL as CFF_code,
NULL as CFF_date,
isnull((select sum(CFF_amt) from @T as a where a.CFF_Loanno = b.CFF_Loanno and a.CFF_repay_date = b.CFF_repay_date), 0) as CFF_amt,
NULL as CFF_repay_date,
NULL as COMP_Name_2
from @T as b group by CFF_Loanno, CFF_repay_date
union all
---明细表
select N'A' as ord,N'明细' as class,c.*
from @T as c
union all
---合计表
select N'C' as ord,N'合计' as class,
CFF_Loanno as CFF_Loanno ,
NULL as BANK_Name_2 ,
NULL as CFF_code,
NULL as CFF_date,
isnull((select sum(CFF_amt) from @T as d where d.CFF_Loanno = e.CFF_Loanno), 0) as CFF_amt,
NULL as CFF_repay_date,
NULL as COMP_Name_2
from @T as e
相关文档:
C#中以windows验证方式连接SQL server数据库的类。很多人连接数据库时可能都是网上查了然后就连了,对于参数的含义倒是没怎么在意,偶也是(呵呵),当然我们都注重结果嘛,可是这样不容易记忆每次连的时候都是上网查,感觉挺不方便,所以索性查了一下。~~~Integrated Security=True;表示在连接数据库进行身份验证时用wind ......
-- create by zh
-- n 是作物的时间,x 是希望在几点成熟,返回播种的时间
with t as
(
select 64 n,9 x from dual union all
select 64 n,13 x from dual union all
select 64 n,17 x from dual union all
select 64 n,20 x from dual
)
select '成熟时间:' || lpad(to_char(n),4,' ' ......
1 防止sql注入式攻击(可用于UI层控制) #region 防止sql注入式攻击(可用于UI层控制)
2
3 /**/ ///
4 /// 判断字符串中是否有SQL攻击代码
5 ///
6 /// 传入用户提交数据
7 /// ......
Five basic search conditions are summarized here:
1) Comparison test
2) Range test
3) Set membership test
4) Pattern matching test (Like)
The pattern matching test checks to see whether the data value in a column matches a specified pattern
% mathes any se ......
SELECT
T.ELES_FLG,
T.SENDUNIT_NAME,
T.ROM_SEQNO,
LTRIM(MAX(SYS_CONNECT_BY_PATH(T.MODEL, ',')), ',') MODEL
from (SELECT
......