我有 3 行需要输出到 1 行,下面的脚本应该可以,但我似乎无法得到预期的结果,它总是显示为 3 行,有什么我遗漏的吗?我应该总结所有字段,因为它们都在“GROUP”子句中吗?
顺便说一句,它就在我对以下结果字段进行更改之前工作;
TSL_DAY_A
TSL_NET_A
TSL_TX_SAL
TSL_CHG
这些字段最初指定为 0.00 作为默认值。
看着它,我的眼睛已经很累了,...
SELECT BR_CODE
,N_CHECK
,CLAS_C
,CLAS_TRD_C
,STOR_NO
,SUM(TSL_NEW_A) AS TSL_NEW_A
,SUM(TSL_OLD_A) AS TSL_OLD_A
,SalesType
,SUM(TSL_DAY_A) AS TSL_DAY_A
,SUM(TSL_DIS_A) AS TSL_DIS_A
,TSL_DIS_B
,SUM(TSL_DIS_C) AS TSL_DIS_C
,TSL_DIS_D
,SUM(TSL_DIS_E) AS TSL_DIS_E
,TSL_Dis_F
,TSL_Dis_G
,TSL_Dis_H
,TSL_Dis_I
,TSL_Dis_J
,TSL_Dis_K
,TSL_Dis_L
,SUM(TSL_TAX_A) AS TSL_TAX_A
,TSL_TAX_B
,TSL_ADJ_A
,TSL_ADJ_POS
,TS_ADJ_NEG
,TSL_ADJ_NT_POS
,TSL_ADJ_NT_NEG
,SUM(TSL_NET_A) AS TSL_NET_A
,SUM(TSL_VOID) AS TSL_VOID
,SUM(TSL_RFND) AS TSL_RFND
,SUM(TSL_TX_SAL) AS TSL_TX_SAL
,SUM(TSL_NX_SAL) AS TSL_NX_SAL
,TSL_CHG
,SUM(TSL_CSH) AS TSL_CSH
,SUM(TSL_GC) AS TSL_GC
,TSL_EPS
,TSL_TND
,TSL_MCRD
,TSL_VISA
,TSL_AMEX
,TSL_DINERS
,TSL_JBC
,TSL_OTCRD
,TSL_SV_CHG
,TSL_OT_CHG
,SUM(TSL_FT) AS TSL_FT
,SUM(TSL_LT) AS TSL_LT
,SUM(TSL_NT) AS TSL_NT
,SUM(TSL_BEG_INV) AS TSL_BEG_INV
,SUM(TSL_END_INV) AS TSL_END_INV
,SUM(TSL_TC_CASH) AS TSL_TC_CASH
,SUM(TSL_TC_GC) AS TSL_TC_GC
,TSL_TC_EPS
,TSL_TC_TND
,TSL_TC_MCD
,TSL_TC_VIS
,TSL_TC_AMX
,TSL_TC_DIN
,TSL_TC_JBC
,TSL_TC_OC
,TSL_MCH
,TSL_SRL
,SUM(TSL_ZCNT) AS TSL_ZCNT
,TSL_TIME
,TSL_DTE
FROM(
SELECT
BR_CODE
,N_CHECK
,CLAS_C
,CLAS_TRD_C
,STOR_NO
,SUM(TSL_NEW_A) AS TSL_NEW_A
,SUM(TSL_OLD_A) AS TSL_OLD_A
,SalesType
,SUM(TSL_DAY_A) AS TSL_DAY_A
,SUM(TSL_DIS_A) AS TSL_DIS_A
,TSL_DIS_B
,SUM(TSL_DIS_C) AS TSL_DIS_C
,TSL_DIS_D
,SUM(TSL_DIS_E) AS TSL_DIS_E
,TSL_Dis_F
,TSL_Dis_G
,TSL_Dis_H
,TSL_Dis_I
,TSL_Dis_J
,TSL_Dis_K
,TSL_Dis_L
,SUM(TSL_TAX_A) AS TSL_TAX_A
,TSL_TAX_B
,TSL_ADJ_A
,TSL_ADJ_POS
,TS_ADJ_NEG
,TSL_ADJ_NT_POS
,TSL_ADJ_NT_NEG
,SUM(TSL_NET_A) AS TSL_NET_A
,SUM(TSL_VOID) AS TSL_VOID
,SUM(TSL_RFND) AS TSL_RFND
,SUM(TSL_TX_SAL) AS TSL_TX_SAL
,SUM(TSL_NX_SAL) AS TSL_NX_SAL
,TSL_CHG
,SUM(TSL_CSH) AS TSL_CSH
,SUM(TSL_GC) AS TSL_GC
,TSL_EPS
,TSL_TND
,TSL_MCRD
,TSL_VISA
,TSL_AMEX
,TSL_DINERS
,TSL_JBC
,TSL_OTCRD
,TSL_SV_CHG
,TSL_OT_CHG
,SUM(TSL_FT) AS TSL_FT
,SUM(TSL_LT) AS TSL_LT
,SUM(TSL_NT) AS TSL_NT
,SUM(TSL_BEG_INV) AS TSL_BEG_INV
,SUM(TSL_END_INV) AS TSL_END_INV
,SUM(TSL_TC_CASH) AS TSL_TC_CASH
,SUM(TSL_TC_GC) AS TSL_TC_GC
,TSL_TC_EPS
,TSL_TC_TND
,TSL_TC_MCD
,TSL_TC_VIS
,TSL_TC_AMX
,TSL_TC_DIN
,TSL_TC_JBC
,TSL_TC_OC
,TSL_MCH
,TSL_SRL
,SUM(TSL_ZCNT) AS TSL_ZCNT
,TSL_TIME
,TSL_DTE
FROM
(SELECT
@branchcode AS BR_CODE
,@ncheck AS N_CHECK
,@classc AS CLAS_C
,@classtrd AS CLAS_TRD_C
,@storeno AS STOR_NO
,SUM(CAST(NGTOTAL AS DECIMAL(16,2)) + CAST(OGTOTAL AS DECIMAL(16,2))) AS TSL_NEW_A
,SUM(CAST(OGTOTAL AS DECIMAL(16,2))) AS TSL_OLD_A
,@salestype AS SalesType
,SUM(((CAST(SALESREGULAR AS DECIMAL(16,2)) - CAST(SALESVATEXEMPT AS DECIMAL(16,2))) +
CAST(SALESCD20 AS DECIMAL(16,2)) +
CAST(SALESCD5 AS DECIMAL(16,2)) +
CAST(SALEPWD AS DECIMAL(16,2)) +
CAST(SALESTGOVT AS DECIMAL(16,2)) +
CAST(SALESZERORATED AS DECIMAL(16,2)) +
CAST(DISCREGULARAMT AS DECIMAL(16,2)) +
CAST(DISCSCD20AMT AS DECIMAL(16,2)) +
CAST(DISCSCD5AMT AS DECIMAL(16,2)) +
CAST(DISCPWD20AMT AS DECIMAL(16,2)) +
CAST(DISCPWD5AMT AS DECIMAL(16,2)) +
CAST(VOIDTRANAMT AS DECIMAL(16,2)) +
CAST(ITEMVOIDAMT AS DECIMAL(16,2)) +
CAST(TICKETRETAMT AS DECIMAL(16,2)) +
CAST(ITEMRETAMT AS DECIMAL(16,2)))/1.12) + CAST(SALESVATEXEMPT AS DECIMAL(16,2)) AS TSL_DAY_A --SUM(cast(round((cast(TSALES as decimal)/1.12),2) AS DECIMAL(16,2))) AS TSL_DAY_A --Help
,SUM(ABS(CAST(DISCREGULARAMT AS DECIMAL(16,2)))) AS TSL_DIS_A
,0.00 AS TSL_DIS_B
,SUM(CAST(DISCSCD20AMT AS DECIMAL(16,2)) + CAST(DISCSCD5AMT AS DECIMAL(16,2))) AS TSL_DIS_C
,0.00 AS TSL_DIS_D
,SUM(CAST(DISCSCD20AMT AS DECIMAL(16,2)) + CAST(DISCSCD5AMT AS DECIMAL(16,2))) AS TSL_DIS_E
,0.00 AS TSL_Dis_F
,0.00 AS TSL_Dis_G
,0.00 AS TSL_Dis_H
,0.00 AS TSL_Dis_I
,0.00 AS TSL_Dis_J
,0.00 AS TSL_Dis_K
,0.00 AS TSL_Dis_L
,SUM(CAST(VATSALEAMT AS DECIMAL(16,2))) AS TSL_TAX_A
,0.00 AS TSL_TAX_B
,0.00 TSL_ADJ_A
,0.00 AS TSL_ADJ_POS
,0.00 AS TS_ADJ_NEG
,0.00 AS TSL_ADJ_NT_POS
,0.00 AS TSL_ADJ_NT_NEG
,SUM(CAST(DGROSSSALES AS DECIMAL(16,2)) - CAST(TOTALTAXVALUE AS DECIMAL(16,2))) AS TSL_NET_A --Help
,SUM(CAST(VOIDTRANAMT AS DECIMAL(16,2))) AS TSL_VOID
,SUM(ABS(CAST(ITEMRETAMT AS DECIMAL(16,2)))) AS TSL_RFND
,SUM(((CAST(SALESREGULAR AS DECIMAL(16,2)) + CAST(SALESVATEXEMPT AS DECIMAL(16,2))) +
CAST(SALESCD20 AS DECIMAL(16,2)) +
CAST(SALESCD5 AS DECIMAL(16,2)) +
CAST(SALEPWD AS DECIMAL(16,2)) +
CAST(SALESTGOVT AS DECIMAL(16,2)) +
CAST(SALESZERORATED AS DECIMAL(16,2)) +
CAST(DISCREGULARAMT AS DECIMAL(16,2)) +
CAST(DISCSCD20AMT AS DECIMAL(16,2)) +
CAST(DISCSCD5AMT AS DECIMAL(16,2)) +
CAST(DISCPWD20AMT AS DECIMAL(16,2)) +
CAST(DISCPWD5AMT AS DECIMAL(16,2)) +
CAST(VOIDTRANAMT AS DECIMAL(16,2)) +
CAST(ITEMVOIDAMT AS DECIMAL(16,2)) +
CAST(TICKETRETAMT AS DECIMAL(16,2)) +
CAST(ITEMRETAMT AS DECIMAL(16,2)))) AS TSL_TX_SAL --Help
,(CAST(SALESVATEXEMPT AS DECIMAL(16,2)) + (CAST(ZERORATEDSALEAMT AS DECIMAL(16,2)) - CAST(ZERORATEDSALETAXVALUE AS DECIMAL(16,2)))) AS TSL_NX_SAL
,SUM(CAST(CCARDATMCHRGONLINEAMT AS DECIMAL(16,2))) AS TSL_CHG --Help
,SUM(CAST(TENDERCASHAMT AS DECIMAL(16,2))) AS TSL_CSH
,SUM(CAST(OTHTENDERSMGCAMT AS DECIMAL(16,2)) + CAST(OTHTENDERSODEXOAMT AS DECIMAL(16,2))) AS TSL_GC --+ CAST(TENDERCHKAMT AS DECIMAL) AS TSL_GC
,0.00 AS TSL_EPS
,0.00 AS TSL_TND
,0.00 AS TSL_MCRD
,0.00 AS TSL_VISA
,0.00 AS TSL_AMEX
,0.00 AS TSL_DINERS
,0.00 AS TSL_JBC
,0.00 AS TSL_OTCRD
,0.00 AS TSL_SV_CHG
,0.00 AS TSL_OT_CHG
,SUM(CAST(ABS(BEGSI) AS INT)) AS TSL_FT
,SUM(CAST(ABS(LASSI) AS INT)) AS TSL_LT
,SUM(CAST((CAST(QTYREGULAR AS DECIMAL(18,2)) + CAST(QTYSCD20 AS DECIMAL(18,2)) + CAST(QTYSCD5 AS DECIMAL(18,2)) + CAST(QTYPWD AS DECIMAL(18,2)) + CAST(QTYTGOVT AS DECIMAL(18,2)) + CAST(QTYZERORATED AS DECIMAL(18,2))
+ CAST(QTYVATEXEMPT AS DECIMAL(18,2)) + CAST(DISCREGULARQTY AS DECIMAL(18,2)) + CAST(DISCSCD20QTY AS DECIMAL(18,2)) + CAST(DISCSCD5QTY AS DECIMAL(18,2)) + CAST(DISCPWD20QTY AS DECIMAL(18,2))
+ CAST(DISCPWD5QTY AS DECIMAL(18,2)) + CAST(VOIDTRANQTY AS DECIMAL(18,2)) + CAST(ITEMVOIDQTY AS DECIMAL(18,2))*-1 + CAST(TICKETRETQTY AS DECIMAL(18,2))*-1 + CAST(ITEMRETQTY AS DECIMAL(18,2))*-1
+ CAST(ADDLOANTOTQTY AS DECIMAL(18,2))) AS INT)) AS TSL_NT
,SUM(CAST(ABS(BEGSI) AS INT)) AS TSL_BEG_INV
,SUM(CAST(ABS(LASSI) AS INT)) AS TSL_END_INV
,SUM(CAST(QTYREGULAR AS INT)) as TSL_TC_CASH
,SUM(CAST(OTHTENDERSMGCQTY AS INT) + CAST(OTHTENDERSODEXOQTY AS INT)) AS TSL_TC_GC --+ CAST(TENDERCHKQTY AS INT) AS TSL_TC_GC
,0 AS TSL_TC_EPS
,0 AS TSL_TC_TND
,0 AS TSL_TC_MCD
,0 AS TSL_TC_VIS
,0 AS TSL_TC_AMX
,0 AS TSL_TC_DIN
,0 AS TSL_TC_JBC
,0 AS TSL_TC_OC
,@machineno AS TSL_MCH
,0 AS TSL_SRL
,SUM(CAST(ABS(ZCOUNTER) AS INT)) AS TSL_ZCNT
--,LEFT(CONVERT(TIME,GETDATE()),8) AS TSL_TIME
,RIGHT('00'+RTRIM(CAST(DATEPART(HH,GETDATE())AS VARCHAR(5))),2)+RIGHT('00'+RTRIM(CAST(DATEPART(MI,GETDATE()) AS VARCHAR(5))),2)+RIGHT('00'+RTRIM(CAST(DATEPART(SS,GETDATE()) AS VARCHAR(5))),2) AS TSL_TIME
--,SUBSTRING(convert(varchar,WorkDate,111),6,2)+'/'+Right(convert(varchar,WorkDate,111),2)+'/'+left(convert(varchar,WorkDate,111),4) AS TSL_DTE
,SUBSTRING(convert(varchar,WorkDate,111),6,2)+Right(convert(varchar,WorkDate,111),2)+left(convert(varchar,WorkDate,111),4) AS TSL_DTE
FROM dbo.TermZTran t
LEFT JOIN
(SELECT sLessee, sTenantNumber AS TenantCode, sStoreNumber FROM mLandlordStore) tInfo
ON CAST(t.STORE AS INT) = CAST(tInfo.sStoreNumber AS INT)
WHERE CAST(t.Store AS INT) = CAST(@branchcode AS INT)
--AND CAST(t.POS AS int) = CAST(@posno AS int)
AND tInfo.sLessee = @lesseeCode
AND CONVERT(nvarchar(10),t.WorkDate,101) = @trandate
--AND CONVERT(nvarchar(10),t.WorkDate,101) = '04/16/2013' --@trandate
GROUP BY
SALESVATEXEMPT
,ZERORATEDSALEAMT
,ZERORATEDSALETAXVALUE
,WorkDate
) tFinal
--WHERE CAST(BR_CODE AS INT) = CAST('0040' AS INT)
GROUP BY
BR_CODE
,N_CHECK
,CLAS_C
,CLAS_TRD_C
,STOR_NO
,TSL_NEW_A
,TSL_OLD_A
,SalesType
,TSL_DAY_A
,TSL_DIS_A
,TSL_DIS_B
,TSL_DIS_C
,TSL_DIS_D
,TSL_DIS_E
,TSL_Dis_F
,TSL_Dis_G
,TSL_Dis_H
,TSL_Dis_I
,TSL_Dis_J
,TSL_Dis_K
,TSL_Dis_L
,TSL_TAX_A
,TSL_TAX_B
,TSL_ADJ_A
,TSL_ADJ_POS
,TS_ADJ_NEG
,TSL_ADJ_NT_POS
,TSL_ADJ_NT_NEG
,TSL_NET_A
,TSL_VOID
,TSL_RFND
,TSL_TX_SAL
,TSL_NX_SAL
,TSL_CHG
,TSL_CSH
,TSL_GC
,TSL_EPS
,TSL_TND
,TSL_MCRD
,TSL_VISA
,TSL_AMEX
,TSL_DINERS
,TSL_JBC
,TSL_OTCRD
,TSL_SV_CHG
,TSL_OT_CHG
,TSL_FT
,TSL_LT
,TSL_NT
,TSL_BEG_INV
,TSL_END_INV
,TSL_TC_CASH
,TSL_TC_GC
,TSL_TC_EPS
,TSL_TC_TND
,TSL_TC_MCD
,TSL_TC_VIS
,TSL_TC_AMX
,TSL_TC_DIN
,TSL_TC_JBC
,TSL_TC_OC
,TSL_MCH
,TSL_SRL
,TSL_ZCNT
,TSL_TIME
,TSL_DTE) dt
GROUP BY
dt.BR_CODE
,dt.CLAS_C
,dt.CLAS_TRD_C
,dt.N_CHECK
,dt.STOR_NO
,dt.SalesType
,TSL_DAY_A
,TSL_DIS_A
,TSL_DIS_B
,TSL_DIS_C
,TSL_DIS_D
,TSL_DIS_E
,TSL_Dis_F
,TSL_Dis_G
,TSL_Dis_H
,TSL_Dis_I
,TSL_Dis_J
,TSL_Dis_K
,TSL_Dis_L
,TSL_TAX_A
,TSL_TAX_B
,TSL_ADJ_A
,TSL_ADJ_POS
,TS_ADJ_NEG
,TSL_ADJ_NT_POS
,TSL_ADJ_NT_NEG
,TSL_NET_A
,TSL_VOID
,TSL_RFND
,TSL_TX_SAL
,TSL_NX_SAL
,TSL_CHG
,TSL_CSH
,TSL_GC
,TSL_EPS
,TSL_TND
,TSL_MCRD
,TSL_VISA
,TSL_AMEX
,TSL_DINERS
,TSL_JBC
,TSL_OTCRD
,TSL_SV_CHG
,TSL_OT_CHG
,TSL_FT
,TSL_LT
,TSL_NT
,TSL_BEG_INV
,TSL_END_INV
,TSL_TC_CASH
,TSL_TC_GC
,TSL_TC_EPS
,TSL_TC_TND
,TSL_TC_MCD
,TSL_TC_VIS
,TSL_TC_AMX
,TSL_TC_DIN
,TSL_TC_JBC
,TSL_TC_OC
,TSL_MCH
,TSL_SRL
,TSL_ZCNT
,TSL_TIME
,TSL_DTE
这是创建示例表和数据的脚本
USE [LandLord]
GO
/****** Object: Table [dbo].[mLandlordStore] Script Date: 04/25/2013 20:21:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[mLandlordStore](
[IDNumber] [int] IDENTITY(1,1) NOT NULL,
[sStoreNumber] [nvarchar](50) NOT NULL,
[sLessee] [nvarchar](50) NOT NULL,
[sLesseeNumber] [int] NOT NULL,
[sHOGenerated] [varchar](1) NOT NULL,
[LastTranNo] [int] NULL,
[sSpace] [nvarchar](50) NULL,
[sMallCode] [nvarchar](20) NULL,
[sTenantNumber] [nvarchar](20) NULL,
[sClassCode] [nvarchar](20) NULL,
[sTradeCode] [nvarchar](20) NULL,
[sOutletNumber] [nvarchar](20) NULL,
[nSaleType] [int] NULL,
[BatchCount] [int] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[mLandlordStore] ON
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (1, N'40', N'SMCOIN', 11002558, N'Y', 0, N'01', N'72', N'011002559', N'01', N'SAP', N'03', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (3, N'1033', N'SMCOIN', 103312345, N'Y', 0, N'01', N'73', N'7312345', N'01', N'SAP', N'04', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (4, N'1133', N'ACI', 113312345, N'Y', 0, N'01', N'74', N'7412345', N'01', N'SAP', N'05', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (5, N'1233', N'ALI', 123312345, N'Y', 0, N'01', N'75', N'7512345', N'01', N'SAP', N'06', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (6, N'1333', N'MWC', 133312345, N'Y', 0, N'01', N'76', N'7612345', N'01', N'SAP', N'07', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (7, N'1433', N'OCLP', 143312345, N'Y', 0, N'01', N'77', N'7712345', N'01', N'SAP', N'08', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (8, N'1533', N'RLC', 153312345, N'Y', 0, N'01', N'78', N'7812345', N'01', N'SAP', N'09', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (9, N'1633', N'SLE', 163312345, N'Y', 0, N'01', N'79', N'7912345', N'01', N'SAP', N'10', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (10, N'1733', N'STAR', 173312345, N'Y', 0, N'01', N'80', N'8012345', N'01', N'SAP', N'11', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (11, N'1833', N'WM', 183312345, N'Y', 0, N'01', N'81', N'8112345', N'01', N'SAP', N'12', 1, 0)
INSERT [dbo].[mLandlordStore] ([IDNumber], [sStoreNumber], [sLessee], [sLesseeNumber], [sHOGenerated], [LastTranNo], [sSpace], [sMallCode], [sTenantNumber], [sClassCode], [sTradeCode], [sOutletNumber], [nSaleType], [BatchCount]) VALUES (12, N'1933', N'FSI', 193312345, N'Y', 0, N'01', N'82', N'8212345', N'01', N'SAP', N'13', 1, 0)
SET IDENTITY_INSERT [dbo].[mLandlordStore] OFF
/****** Object: Default [DF_mLandlordStore_LastTranNo] Script Date: 04/25/2013 20:21:42 ******/
ALTER TABLE [dbo].[mLandlordStore] ADD CONSTRAINT [DF_mLandlordStore_LastTranNo] DEFAULT ((1)) FOR [LastTranNo]
GO
USE [LandLord]
GO
/****** Object: Table [dbo].[TermZTran] Script Date: 04/25/2013 20:19:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TermZTran](
[HeaderID] [uniqueidentifier] NOT NULL,
[WorkDate] [smalldatetime] NOT NULL,
[ProcessDate] [smalldatetime] NOT NULL,
[ProcessMode] [nvarchar](10) NOT NULL,
[POSCount] [int] NULL,
[SalePharma] [money] NULL,
[SaleNonPharma] [money] NULL,
[VoidAmount] [money] NULL,
[VoidCount] [int] NULL,
[ZCOUNTER] [nvarchar](4000) NULL,
[STORE] [nvarchar](4000) NULL,
[POS] [nvarchar](4000) NULL,
[DATE] [nvarchar](300) NULL,
[TIME] [nvarchar](300) NULL,
[OGTOTAL] [nvarchar](300) NULL,
[NGTOTAL] [nvarchar](300) NULL,
[BEGSI] [nvarchar](300) NULL,
[LASSI] [nvarchar](300) NULL,
[TSALES] [nvarchar](300) NULL,
[QTYREGULAR] [nvarchar](300) NULL,
[SALESREGULAR] [nvarchar](300) NULL,
[QTYSCD20] [nvarchar](300) NULL,
[SALESCD20] [nvarchar](300) NULL,
[QTYSCD5] [nvarchar](300) NULL,
[SALESCD5] [nvarchar](300) NULL,
[QTYPWD] [nvarchar](300) NULL,
[SALEPWD] [nvarchar](300) NULL,
[QTYTGOVT] [nvarchar](300) NULL,
[SALESTGOVT] [nvarchar](300) NULL,
[QTYZERORATED] [nvarchar](300) NULL,
[SALESZERORATED] [nvarchar](300) NULL,
[QTYVATEXEMPT] [nvarchar](300) NULL,
[SALESVATEXEMPT] [nvarchar](300) NULL,
[TDISCOUNT] [nvarchar](300) NULL,
[DISCREGULARQTY] [nvarchar](300) NULL,
[DISCREGULARAMT] [nvarchar](300) NULL,
[DISCSCD20QTY] [nvarchar](300) NULL,
[DISCSCD20AMT] [nvarchar](300) NULL,
[DISCSCD5QTY] [nvarchar](300) NULL,
[DISCSCD5AMT] [nvarchar](300) NULL,
[DISCPWD20QTY] [nvarchar](300) NULL,
[DISCPWD20AMT] [nvarchar](300) NULL,
[DISCPWD5QTY] [nvarchar](300) NULL,
[DISCPWD5AMT] [nvarchar](300) NULL,
[DNETSALES] [nvarchar](300) NULL,
[DGROSSSALES] [nvarchar](300) NULL,
[SALESACCOUNTABILITY] [nvarchar](300) NULL,
[VOIDTRANQTY] [nvarchar](300) NULL,
[VOIDTRANAMT] [nvarchar](300) NULL,
[ITEMVOIDQTY] [nvarchar](300) NULL,
[ITEMVOIDAMT] [nvarchar](300) NULL,
[TICKETRETQTY] [nvarchar](300) NULL,
[TICKETRETAMT] [nvarchar](300) NULL,
[ITEMRETQTY] [nvarchar](300) NULL,
[ITEMRETAMT] [nvarchar](300) NULL,
[ADDLOANTOTQTY] [nvarchar](300) NULL,
[ADDLOANTOTAMT] [nvarchar](300) NULL,
[TENDERCASHQTY] [nvarchar](300) NULL,
[TENDERCASHAMT] [nvarchar](300) NULL,
[TENDERATMOFFLINEQTY] [nvarchar](300) NULL,
[TENDERATMOFFLINEAMT] [nvarchar](300) NULL,
[TENDERCHRGOFFLINEQTY] [nvarchar](300) NULL,
[TENDERCHRGOFFLINEAMT] [nvarchar](300) NULL,
[TENDERCHKQTY] [nvarchar](300) NULL,
[TENDERCHKAMT] [nvarchar](300) NULL,
[TENDERBDOREBATESQTY] [nvarchar](300) NULL,
[TENDERBDOREBATESAMT] [nvarchar](300) NULL,
[OVERTENDERQTY] [nvarchar](300) NULL,
[OVERTENDERAMT] [nvarchar](300) NULL,
[OTHERTENDERQTY] [nvarchar](300) NULL,
[OTHERTENDERAMT] [nvarchar](300) NULL,
[TENDERCCMQTY] [nvarchar](300) NULL,
[TENDERCCMAMT] [nvarchar](300) NULL,
[TENDERARCODQTY] [nvarchar](300) NULL,
[TENDERARCODAMT] [nvarchar](300) NULL,
[TENDERADBQTY] [nvarchar](300) NULL,
[TENDERADBAMT] [nvarchar](300) NULL,
[TENDERFWV5QTY] [nvarchar](300) NULL,
[TENDERFWV5AMT] [nvarchar](300) NULL,
[TENDEREWT1QTY] [nvarchar](300) NULL,
[TENDEREWT1AMT] [nvarchar](300) NULL,
[TENDERTOP20KQTY] [nvarchar](300) NULL,
[TENDERTOP20KAMT] [nvarchar](300) NULL,
[CCARDATMCHRGONLINEQTY] [nvarchar](300) NULL,
[CCARDATMCHRGONLINEAMT] [nvarchar](300) NULL,
[OTHTENDERSMGCQTY] [nvarchar](300) NULL,
[OTHTENDERSMGCAMT] [nvarchar](300) NULL,
[OTHTENDERSODEXOQTY] [nvarchar](300) NULL,
[OTHTENDERSODEXOAMT] [nvarchar](300) NULL,
[OTHTENDERCORPACCQTY] [nvarchar](300) NULL,
[OTHTENDERCORPACCAMT] [nvarchar](300) NULL,
[OTHTENDERDIFFEREDQTY] [nvarchar](300) NULL,
[OTHTENDERDIFFEREDAMT] [nvarchar](300) NULL,
[TENDERTOTAL] [nvarchar](300) NULL,
[VATSALEAMT] [nvarchar](300) NULL,
[VATSALETAXVALUE] [nvarchar](300) NULL,
[VATEXSALEAMT] [nvarchar](300) NULL,
[VATEXSALETAXVALUE] [nvarchar](300) NULL,
[ZERORATEDSALEAMT] [nvarchar](300) NULL,
[ZERORATEDSALETAXVALUE] [nvarchar](300) NULL,
[TOTALAMT] [nvarchar](300) NULL,
[TOTALTAXVALUE] [nvarchar](300) NULL
) ON [PRIMARY]
GO
INSERT [dbo].[TermZTran] ([HeaderID], [WorkDate], [ProcessDate], [ProcessMode], [POSCount], [SalePharma], [SaleNonPharma], [VoidAmount], [VoidCount], [ZCOUNTER], [STORE], [POS], [DATE], [TIME], [OGTOTAL], [NGTOTAL], [BEGSI], [LASSI], [TSALES], [QTYREGULAR], [SALESREGULAR], [QTYSCD20], [SALESCD20], [QTYSCD5], [SALESCD5], [QTYPWD], [SALEPWD], [QTYTGOVT], [SALESTGOVT], [QTYZERORATED], [SALESZERORATED], [QTYVATEXEMPT], [SALESVATEXEMPT], [TDISCOUNT], [DISCREGULARQTY], [DISCREGULARAMT], [DISCSCD20QTY], [DISCSCD20AMT], [DISCSCD5QTY], [DISCSCD5AMT], [DISCPWD20QTY], [DISCPWD20AMT], [DISCPWD5QTY], [DISCPWD5AMT], [DNETSALES], [DGROSSSALES], [SALESACCOUNTABILITY], [VOIDTRANQTY], [VOIDTRANAMT], [ITEMVOIDQTY], [ITEMVOIDAMT], [TICKETRETQTY], [TICKETRETAMT], [ITEMRETQTY], [ITEMRETAMT], [ADDLOANTOTQTY], [ADDLOANTOTAMT], [TENDERCASHQTY], [TENDERCASHAMT], [TENDERATMOFFLINEQTY], [TENDERATMOFFLINEAMT], [TENDERCHRGOFFLINEQTY], [TENDERCHRGOFFLINEAMT], [TENDERCHKQTY], [TENDERCHKAMT], [TENDERBDOREBATESQTY], [TENDERBDOREBATESAMT], [OVERTENDERQTY], [OVERTENDERAMT], [OTHERTENDERQTY], [OTHERTENDERAMT], [TENDERCCMQTY], [TENDERCCMAMT], [TENDERARCODQTY], [TENDERARCODAMT], [TENDERADBQTY], [TENDERADBAMT], [TENDERFWV5QTY], [TENDERFWV5AMT], [TENDEREWT1QTY], [TENDEREWT1AMT], [TENDERTOP20KQTY], [TENDERTOP20KAMT], [CCARDATMCHRGONLINEQTY], [CCARDATMCHRGONLINEAMT], [OTHTENDERSMGCQTY], [OTHTENDERSMGCAMT], [OTHTENDERSODEXOQTY], [OTHTENDERSODEXOAMT], [OTHTENDERCORPACCQTY], [OTHTENDERCORPACCAMT], [OTHTENDERDIFFEREDQTY], [OTHTENDERDIFFEREDAMT], [TENDERTOTAL], [VATSALEAMT], [VATSALETAXVALUE], [VATEXSALEAMT], [VATEXSALETAXVALUE], [ZERORATEDSALEAMT], [ZERORATEDSALETAXVALUE], [TOTALAMT], [TOTALTAXVALUE]) VALUES (N'35a9637c-4342-4cb4-8f10-1c1d52b09cd4', CAST(0xA1A20000 AS SmallDateTime), CAST(0xA1A80478 AS SmallDateTime), N'sqljob', 1, 0.0000, 0.0000, 0.0000, 0, N'0001', N'0040', N'001', N'16/04/2013', N'19:06', N'0.00', N'73420.22', N'0000000001', N'0000000078', N'69827.81', N'75', N'48543.85', N'7', N'15683.96', N'4', N'940.00', N'6', N'4520.00', N'0', N'0.00', N'0', N'0.00', N'1', N'140.00', N'8283.98', N'30', N'4361.04', N'7', N'3136.79', N'4', N'41.96', N'3', N'723.21', N'3', N'20.98', N'56502.49', N'73420.22', N'61760.30', N'3', N'5815.95', N'-33', N'-1282.50', N'-14', N'-5886.00', N'-151', N'-3923.18', N'2', N'6000.00', N'68', N'46045.65', N'1', N'67.50', N'3', N'751.75', N'1', N'3200.00', N'2', N'310.82', N'2', N'-3.00', N'3', N'0.03', N'0', N'0.00', N'0', N'0.00', N'0', N'0', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'11', N'9096.12', N'5', N'800.00', N'5', N'450.00', N'1', N'1041.43', N'0', N'0.00', N'61760.30', N'43815.32', N'5257.81', N'15823.96', N'0.00', N'0.00', N'0.00', N'59639.28', N'5257.81')
INSERT [dbo].[TermZTran] ([HeaderID], [WorkDate], [ProcessDate], [ProcessMode], [POSCount], [SalePharma], [SaleNonPharma], [VoidAmount], [VoidCount], [ZCOUNTER], [STORE], [POS], [DATE], [TIME], [OGTOTAL], [NGTOTAL], [BEGSI], [LASSI], [TSALES], [QTYREGULAR], [SALESREGULAR], [QTYSCD20], [SALESCD20], [QTYSCD5], [SALESCD5], [QTYPWD], [SALEPWD], [QTYTGOVT], [SALESTGOVT], [QTYZERORATED], [SALESZERORATED], [QTYVATEXEMPT], [SALESVATEXEMPT], [TDISCOUNT], [DISCREGULARQTY], [DISCREGULARAMT], [DISCSCD20QTY], [DISCSCD20AMT], [DISCSCD5QTY], [DISCSCD5AMT], [DISCPWD20QTY], [DISCPWD20AMT], [DISCPWD5QTY], [DISCPWD5AMT], [DNETSALES], [DGROSSSALES], [SALESACCOUNTABILITY], [VOIDTRANQTY], [VOIDTRANAMT], [ITEMVOIDQTY], [ITEMVOIDAMT], [TICKETRETQTY], [TICKETRETAMT], [ITEMRETQTY], [ITEMRETAMT], [ADDLOANTOTQTY], [ADDLOANTOTAMT], [TENDERCASHQTY], [TENDERCASHAMT], [TENDERATMOFFLINEQTY], [TENDERATMOFFLINEAMT], [TENDERCHRGOFFLINEQTY], [TENDERCHRGOFFLINEAMT], [TENDERCHKQTY], [TENDERCHKAMT], [TENDERBDOREBATESQTY], [TENDERBDOREBATESAMT], [OVERTENDERQTY], [OVERTENDERAMT], [OTHERTENDERQTY], [OTHERTENDERAMT], [TENDERCCMQTY], [TENDERCCMAMT], [TENDERARCODQTY], [TENDERARCODAMT], [TENDERADBQTY], [TENDERADBAMT], [TENDERFWV5QTY], [TENDERFWV5AMT], [TENDEREWT1QTY], [TENDEREWT1AMT], [TENDERTOP20KQTY], [TENDERTOP20KAMT], [CCARDATMCHRGONLINEQTY], [CCARDATMCHRGONLINEAMT], [OTHTENDERSMGCQTY], [OTHTENDERSMGCAMT], [OTHTENDERSODEXOQTY], [OTHTENDERSODEXOAMT], [OTHTENDERCORPACCQTY], [OTHTENDERCORPACCAMT], [OTHTENDERDIFFEREDQTY], [OTHTENDERDIFFEREDAMT], [TENDERTOTAL], [VATSALEAMT], [VATSALETAXVALUE], [VATEXSALEAMT], [VATEXSALETAXVALUE], [ZERORATEDSALEAMT], [ZERORATEDSALETAXVALUE], [TOTALAMT], [TOTALTAXVALUE]) VALUES (N'35a9637c-4342-4cb4-8f10-1c1d52b09cd4', CAST(0xA1A20000 AS SmallDateTime), CAST(0xA1A80478 AS SmallDateTime), N'sqljob', 2, 0.0000, 0.0000, 0.0000, 0, N'0001', N'0040', N'002', N'16/04/2013', N'19:06', N'0.00', N'60296.14', N'0000000001', N'0000000076', N'58336.24', N'61', N'44770.01', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'7', N'4597.00', N'15', N'8269.23', N'4', N'700.00', N'3890.95', N'17', N'3890.95', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'49572.91', N'60296.14', N'54445.29', N'2', N'186.00', N'-133', N'-3567.50', N'-7', N'-6661.50', N'-90', N'-2085.50', N'2', N'6000.00', N'66', N'39251.01', N'1', N'67.50', N'1', N'149.00', N'0', N'0.00', N'0', N'0.00', N'3', N'-22.68', N'10', N'3989.88', N'0', N'0.00', N'0', N'0.00', N'0', N'0', N'11', N'205.23', N'11', N'41.05', N'13', N'41.05', N'8', N'4323.75', N'9', N'2500.00', N'1', N'100.00', N'2', N'3799.50', N'0', N'0.00', N'54445.29', N'40603.68', N'4872.38', N'700.00', N'0.00', N'8269.23', N'0.00', N'49572.91', N'4872.38')
INSERT [dbo].[TermZTran] ([HeaderID], [WorkDate], [ProcessDate], [ProcessMode], [POSCount], [SalePharma], [SaleNonPharma], [VoidAmount], [VoidCount], [ZCOUNTER], [STORE], [POS], [DATE], [TIME], [OGTOTAL], [NGTOTAL], [BEGSI], [LASSI], [TSALES], [QTYREGULAR], [SALESREGULAR], [QTYSCD20], [SALESCD20], [QTYSCD5], [SALESCD5], [QTYPWD], [SALEPWD], [QTYTGOVT], [SALESTGOVT], [QTYZERORATED], [SALESZERORATED], [QTYVATEXEMPT], [SALESVATEXEMPT], [TDISCOUNT], [DISCREGULARQTY], [DISCREGULARAMT], [DISCSCD20QTY], [DISCSCD20AMT], [DISCSCD5QTY], [DISCSCD5AMT], [DISCPWD20QTY], [DISCPWD20AMT], [DISCPWD5QTY], [DISCPWD5AMT], [DNETSALES], [DGROSSSALES], [SALESACCOUNTABILITY], [VOIDTRANQTY], [VOIDTRANAMT], [ITEMVOIDQTY], [ITEMVOIDAMT], [TICKETRETQTY], [TICKETRETAMT], [ITEMRETQTY], [ITEMRETAMT], [ADDLOANTOTQTY], [ADDLOANTOTAMT], [TENDERCASHQTY], [TENDERCASHAMT], [TENDERATMOFFLINEQTY], [TENDERATMOFFLINEAMT], [TENDERCHRGOFFLINEQTY], [TENDERCHRGOFFLINEAMT], [TENDERCHKQTY], [TENDERCHKAMT], [TENDERBDOREBATESQTY], [TENDERBDOREBATESAMT], [OVERTENDERQTY], [OVERTENDERAMT], [OTHERTENDERQTY], [OTHERTENDERAMT], [TENDERCCMQTY], [TENDERCCMAMT], [TENDERARCODQTY], [TENDERARCODAMT], [TENDERADBQTY], [TENDERADBAMT], [TENDERFWV5QTY], [TENDERFWV5AMT], [TENDEREWT1QTY], [TENDEREWT1AMT], [TENDERTOP20KQTY], [TENDERTOP20KAMT], [CCARDATMCHRGONLINEQTY], [CCARDATMCHRGONLINEAMT], [OTHTENDERSMGCQTY], [OTHTENDERSMGCAMT], [OTHTENDERSODEXOQTY], [OTHTENDERSODEXOAMT], [OTHTENDERCORPACCQTY], [OTHTENDERCORPACCAMT], [OTHTENDERDIFFEREDQTY], [OTHTENDERDIFFEREDAMT], [TENDERTOTAL], [VATSALEAMT], [VATSALETAXVALUE], [VATEXSALEAMT], [VATEXSALETAXVALUE], [ZERORATEDSALEAMT], [ZERORATEDSALETAXVALUE], [TOTALAMT], [TOTALTAXVALUE]) VALUES (N'35a9637c-4342-4cb4-8f10-1c1d52b09cd4', CAST(0xA1A20000 AS SmallDateTime), CAST(0xA1A80478 AS SmallDateTime), N'sqljob', 3, 0.0000, 0.0000, 0.0000, 0, N'0001', N'0040', N'003', N'16/04/2013', N'19:06', N'0.00', N'0.00', N'0000000000', N'0000000000', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0.00', N'0.00', N'0.00', N'1', N'0.01', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0', N'0.00', N'0.00', N'0.00', N'0.00', N'0.00', N'0.00', N'0.00', N'0.00', N'0.00', N'0.00')
请帮忙...