You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/word/新协航_设计文档/数据库建表文档/1.0/报表_客户对账.sql

46 lines
3.8 KiB
MySQL

3 years ago
<EFBFBD><EFBFBD>--update ch_fee set amount=unitprice*quantity
--select * from ch_fee
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[vImprotRPT_KHDZ]'))
DROP VIEW [dbo].[vImprotRPT_KHDZ]
GO
/****** Object: View [dbo].[vImprotRPT_KHDZ] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[vImprotRPT_KHDZ]
AS
select bsno,sum(<EFBFBD><EFBFBD><EFBFBD>N>k) <EFBFBD><EFBFBD><EFBFBD>N>k,sum(>\>k) >\>k,sum(<EFBFBD>X<Pz) <EFBFBD>X<Pz,sum(sQz) sQz
,sum(<EFBFBD>Nt9<EFBFBD>) <EFBFBD>Nt9<EFBFBD>,sum(THC) THC,sum(<EFBFBD>bf<EFBFBD>9<EFBFBD>) <EFBFBD>bf<EFBFBD>9<EFBFBD>,sum(<EFBFBD><EFBFBD>'<EFBFBD>9<EFBFBD>) <00><>'<EFBFBD>9<EFBFBD>
,sum(<EFBFBD>ng9<EFBFBD>) <EFBFBD>ng9<EFBFBD>,sum(<EFBFBD><EFBFBD>g6R<EFBFBD>Q9<EFBFBD>) <EFBFBD><EFBFBD>g6R<EFBFBD>Q9<EFBFBD>,sum(<EFBFBD>Qυ9<EFBFBD>) <EFBFBD>Qυ9<EFBFBD>,sum(<EFBFBD>QeQ<EFBFBD>^9<EFBFBD>) <EFBFBD>QeQ<EFBFBD>^9<EFBFBD>
,sum(<EFBFBD><EFBFBD><EFBFBD>N>k)+sum(>\>k)+sum(<EFBFBD>X<Pz)+sum(sQz)+sum(<EFBFBD>Nt9<EFBFBD>)+sum(THC)+sum(<EFBFBD>bf<EFBFBD>9<EFBFBD>)+sum(<EFBFBD><EFBFBD>'<EFBFBD>9<EFBFBD>)+
sum(<EFBFBD>ng9<EFBFBD>)+sum(<EFBFBD><EFBFBD>g6R<EFBFBD>Q9<EFBFBD>)+sum(<EFBFBD>Qυ9<EFBFBD>)+sum(<EFBFBD>QeQ<EFBFBD>^9<EFBFBD>) \<EFBFBD><EFBFBD>
from(
select bsno,
case feename when '<00><><EFBFBD>N>k' then convert(numeric(18,2), amount*exchangerate) else 0 end [<EFBFBD><EFBFBD><EFBFBD>N>k],
case feename when '>\>k' then convert(numeric(18,2), amount*exchangerate) else 0 end [>\>k],
case feename when '<00>X<Pz' then convert(numeric(18,2), amount*exchangerate) else 0 end [<EFBFBD>X<Pz],
case feename when 'sQz' then convert(numeric(18,2),amount*exchangerate) else 0 end [sQz],
case feename when '<00>Nt9<74>' then convert(numeric(18,2),amount*exchangerate) else 0 end [<EFBFBD>Nt9<EFBFBD>],
case feename when 'THC' then convert(numeric(18,2),amount*exchangerate) else 0 end [THC],
case feename when '<00>bf<62>9<EFBFBD>' then convert(numeric(18,2),amount*exchangerate) else 0 end [<EFBFBD>bf<EFBFBD>9<EFBFBD>],
case feename when '<00><>'<EFBFBD>9<EFBFBD>' then convert(numeric(18,2),amount*exchangerate) else 0 end [<00><>'<EFBFBD>9<EFBFBD>],
case feename when '<00>ng9<67>' then convert(numeric(18,2),amount*exchangerate) else 0 end [<EFBFBD>ng9<EFBFBD>],
case feename when '<00><>g6R<36>Q9<51>' then convert(numeric(18,2),amount*exchangerate) else 0 end [<EFBFBD><EFBFBD>g6R<EFBFBD>Q9<EFBFBD>],
case feename when '<00>Qυ9<CF85>' then convert(numeric(18,2),amount*exchangerate) else 0 end [<EFBFBD>Qυ9<EFBFBD>],
case feename when '<00>QeQ<65>^9<>' then convert(numeric(18,2),amount*exchangerate) else 0 end [<EFBFBD>QeQ<EFBFBD>^9<EFBFBD>]
from ch_fee where feetype=1
) tt
group by tt.bsno
--where bsno='A1'
select * from [vImprotRPT_KHDZ]
where bsno in(select contractno from import_main m where (1=1) )