2018-07-01

select ID uwayid,NetName 渠道类型, Valid 是否在用,'网络' as 来院类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from NetChannel cw where Valid=1 union
select ID uwayid, UnderstandWayName 渠道类型, 1 是否在用,'电话'as 来源类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from CustomerUnderstandWay cu order by 来院类型

select ID uwayid,NetName 渠道类型, Valid 是否在用,'网络' as 来院类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from NetChannel cw where Valid=1

select ID uwayid, UnderstandWayName 渠道类型, 1 是否在用,'电话'as 来源类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from CustomerUnderstandWay cu

select ID uwayid,NetName 渠道类型, Valid 是否在用,'网络' as 来院类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from NetChannel cw where Valid=1

select ID uwayid, UnderstandWayName 渠道类型, 1 是否在用,'电话'as 来院类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from CustomerUnderstandWay cu order by 来院类型

select sta.Status,suc.Success, base.TMKEmployee, base.SceneEmployee,come.Date,base.UnderstandWayID as ChannelID,
cu.UnderstandWayName as ChannelName
from CustomerComeLog come
inner join CustomerBaseInfo base on base.ID = come.CustomerID
inner join CustomerUnderstandWay cu on cu.ID=base.UnderstandWayID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID where 1=1 and Date> '2018-06-30 00:00:00' and Date<'2018-07-01 00:00:00' group by sta.Status, base.TMKEmployee,base.SceneEmployee,come.Date,base.UnderstandWayID,cu.UnderstandWayName,suc.Success

select sta.Status,suc.Success, base.TMKEmployee, base.SceneEmployee,come.Date,base.NetChannelID as ChannelID,nc.NetName as ChannelName
from CustomerComeLog come
inner join CustomerBaseInfo base on base.NetChannelID = come.CustomerID
inner join NetChannel nc on nc.ID=base.NetChannelID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID

select sta.Status,suc.Success, base.TMKEmployee, base.SceneEmployee,come.Date,base.UnderstandWayID as UnderstandWayID,
cu.UnderstandWayName as UnderstandWayName
from CustomerComeLog come
inner join CustomerBaseInfo base on base.ID = come.CustomerID
inner join CustomerUnderstandWay cu on cu.ID=base.UnderstandWayID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID

select sta.Status,suc.Success, base.TMKEmployee, base.SceneEmployee,come.Date,base.UnderstandWayID as UnderstandWayID,
cu.UnderstandWayName as UnderstandWayName
from CustomerComeLog come
inner join CustomerBaseInfo base on base.ID = come.CustomerID
inner join CustomerUnderstandWay cu on cu.ID=base.UnderstandWayID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID

select sum(fin.AllTotal) money, sta.Status,base.UnderstandWayID as ChannelID ,cu.UnderstandWayName as ChannelName
from FinanceTotal fin
inner join CustomerBaseInfo base on base.ID = fin.CustomerID
inner join CustomerUnderstandWay cu on cu.ID=base.UnderstandWayID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID
where 1=1 group by sta.Status, base.UnderstandWayID,cu.UnderstandWayName

select sta.Status,suc.Success, base.TMKEmployee, base.SceneEmployee,come.Date,base.NetChannelID as ChannelID,nc.NetName as ChannelName
from CustomerComeLog come
inner join CustomerBaseInfo base on base.NetChannelID = come.CustomerID
inner join NetChannel nc on nc.ID=base.NetChannelID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID where 1=1 and Date> '2018-06-30 00:00:00' and Date<'2018-07-01 00:00:00' group by sta.Status,suc.Success, base.NetChannelID,nc.NetName

select sum(fin.AllTotal) money, sta.Status,base.NetChannelID ChannelID,nc.NetName ChannelName
from FinanceTotal fin
inner join CustomerBaseInfo base on base.ID = fin.CustomerID
inner join NetChannel nc on nc.ID=base.NetChannelID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID
where 1=1 and Date> '2018-06-29 00:00:00' and Date<'2018-07-01 00:00:00'group by sta.Status,base.NetChannelID,nc.NetName

select sta.Status,suc.Success, base.TMKEmployee, base.SceneEmployee,come.Date,base.NetChannelID as ChannelID,nc.NetName as ChannelName
from CustomerComeLog come
inner join CustomerBaseInfo base on base.NetChannelID = come.CustomerID
inner join NetChannel nc on nc.ID=base.NetChannelID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID

select NetChannelID from CustomerBaseInfo where NetChannelID is not NULL;

select sub.ID subID, sub.Name 部位, dept.ID deptID, dept.Name 部门, emp.ID empID, emp.Name 姓名,
sub.ContainsCategories, sub.ContainsConsultingCategories,
0 初诊上门量, 0 初诊成交量, 0 复诊上门量, 0 复诊成交量, 0 老顾客上门量,0 老顾客成交量
from CountSettingsForSubCategory sub, Employee emp, PositionInfo pos, Department dept
where sub.ID in(4,5,6,7,11) and dept.ID in (006,004,034)
and emp.Valid=1
and emp.PositionID=pos.ID
and pos.DepartmentID=dept.ID
order by sub.ID, dept.ID, emp.ID

select * from CustomerComeLog

select come.CountSettingsSubCategoryID, sta.Status,
suc.Success, base.TMKEmployee, base.SceneEmployee,base.RegisterDate,base.Name
from CustomerComeLog come
inner join CustomerBaseInfo base on base.ID = come.CustomerID
inner join Employee emp on emp.ID=base.TMKEmployee
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID where 1=1 and Date> '2018-06-01 00:00:00' and Date<'2018-07-01 00:00:00'

select count(*),Success from SuccessOfCustomer group by Success

select * from CustomerComeLog where Date>'2018-06-22 13:37:34.450'
select * from CountSettingsForSubCategory
select * from CountSettings;

select * from CustomerBaseInfo where ID='O6IKJLVC2M'

select * from CustomerComeLog where CustomerID='O6IKJLVC2M'

SELECT [t0].[Booker], [t0].[ChatID], [t0].[ConsultingBy], [t0].[ConsultingContent], [t0].[ConsultingDate], [t0].[ExcutionNumber], [t0].[ID], [t0].[ConsumptionItention], [t0].[CustomerID], [t0].[ItemCategoryID], [t0].[Keyword], [t0].[Status], [t0].[Webaddress]
FROM [dbo].[ConsultingProjects] AS [t0]
INNER JOIN [dbo].[ConsultingInfo] AS [t1] ON [t1].[ExcutionNumber] = [t0].[ExcutionNumber]
WHERE [t1].[CustomerID] = 'O6IKJLVC2M'
ORDER BY [t0].[ConsultingDate] DESC

select * from CustomerConsumptionInfo where CustomerID='O6IKJLVC2M'

select * from CustomerConsumptionInfo where CustomerID='O6IKJLVC2M'

select * from CustomerConsumptionDetails where ExcutionNumber='GT0V67VKOQEG'

select * from CountSettingsForSubCategory where ContainsCategories like '%00046%'

 


 

exec sp_executesql N'SELECT [t0].[Date] AS [ComeDate], [t0].[CustomerID], [t1].[Name] AS [CustomerName], [t1].[FirstPhone] AS [CustomerPhone], [t0].[ID] AS [Id], [t2].[MemberCardNum], [t3].[Name] AS [RegisterBy], [t5].[Name] AS [RegisterDept],
(CASE
WHEN [t1].[SceneEmployee] IS NOT NULL THEN CONVERT(NVarChar(MAX),[t6].[Name])
ELSE NULL
END) AS [SceneName], [t1].[Sex], CONVERT(NVarChar,[t1].[Age]) AS [Age]
FROM [dbo].[CustomerComeLog] AS [t0]
INNER JOIN [dbo].[CustomerBaseInfo] AS [t1] ON [t1].[ID] = [t0].[CustomerID]
LEFT OUTER JOIN [dbo].[MemberCardInfo] AS [t2] ON [t2].[CustomerID] = [t1].[ID]
INNER JOIN [dbo].[Employee] AS [t3] ON [t3].[ID] = [t0].[HandleBy]
INNER JOIN [dbo].[PositionInfo] AS [t4] ON [t4].[ID] = [t3].[PositionID]
INNER JOIN [dbo].[Department] AS [t5] ON [t5].[ID] = [t4].[DepartmentID]
LEFT OUTER JOIN [dbo].[Employee] AS [t6] ON [t6].[ID] = [t1].[SceneEmployee]
WHERE ([t0].[Date] >= @p0) AND ([t0].[Date] < @p1) AND ([t1].[Name] LIKE @p2) AND (NOT ([t1].[Remove] = 1)) AND ((
(CASE
WHEN @p3 = 1 THEN
(CASE
WHEN ([t2].[MemberCardNum] IS NOT NULL) AND ([t2].[MemberCardNum] LIKE @p4) THEN 1
WHEN NOT (([t2].[MemberCardNum] IS NOT NULL) AND ([t2].[MemberCardNum] LIKE @p4)) THEN 0
ELSE NULL
END)
WHEN [t2].[MemberCardNum] IS NOT NULL THEN CONVERT(Int,
(CASE
WHEN [t2].[MemberCardNum] LIKE @p5 THEN 1
WHEN NOT ([t2].[MemberCardNum] LIKE @p5) THEN 0
ELSE NULL
END))
ELSE @p6
END)) = 1)',N'@p0 datetime,@p1 datetime,@p2 nvarchar(4000),@p3 int,@p4 varchar(8000),@p5 varchar(8000),@p6 int',@p0='2018-06-26 00:00:00',@p1='2018-06-27 00:00:00',@p2=N'%%',@p3=0,@p4='%%',@p5='%%',@p6=1

select come.CountSettingsSubCategoryID, sta.Status,
suc.Success, base.SceneEmployee, base.SceneEmployee,come.Date
from CustomerComeLog come
inner join CustomerBaseInfo base on base.ID = come.CustomerID
inner join Employee emp on emp.ID=base.SceneEmployee
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID

select * from CustomerComeLog

select * from H_TMK;

select distinct(PresentationMode) from CustomerBaseInfo;

select * from CustomerBaseInfo where PresentationMode=1

select * from bh20180529.dbo.CustomerAppendInfo where ReferralsID is not NULL

select count(*) from CustomerAppendInfo
select count(*) from CustomerBaseInfo;

update CustomerAppendInfo

exec sp_executesql N'SELECT
(CASE
WHEN [t0].[AnesthetistID] IS NOT NULL THEN CONVERT(NVarChar(MAX),[t4].[Name])
ELSE NULL
END) AS [AnesthetistName], [t0].[ArrearsAmount],
(CASE
WHEN [t0].[FirstAssistantID] IS NOT NULL THEN CONVERT(NVarChar(MAX),[t5].[Name])
ELSE NULL
END) AS [AssistantName],
(CASE
WHEN [t0].[SecondAssistantID] IS NOT NULL THEN CONVERT(NVarChar(MAX),[t6].[Name])
ELSE NULL
END) AS [AssistantTwoName], [t0].[CashAmount], [t9].[ChargeDate] AS [ChargeDate], [t0].[CustomerID], [t1].[Name] AS [CustomerName], [t10].[DDDID] AS [DeptID], [t10].[Name] AS [DeptName],
(CASE
WHEN [t0].[DoctorID] IS NOT NULL THEN CONVERT(NVarChar(MAX),[t11].[Name])
ELSE NULL
END) AS [DoctorName], [t0].[Date] AS [ExcuteDate], [t0].[ExcuteInfoID], [t0].[ExcuteQuantity], [t0].[Excutetimes] AS [ExcuteTimes], [t0].[ID], [t0].[InsteadMoneyAmount], [t0].[IntegrationAmount], [t8].[ExecuteStatus] AS [ItemExecuteStatus], [t3].[Name] AS [ItemName], [t3].[Standard] AS [ItemStandard], [t12].[ItemTypeName] AS [ItemStyle], [t13].[Name] AS [ItemTopCategory],
(CASE
WHEN (CONVERT(Int,[t0].[KindofSicknessID])) IS NOT NULL THEN [t14].[Name]
ELSE CONVERT(NVarChar(50),@p20)
END) AS [KindofSickness], [t2].[MemberCardNum] AS [MemberCard], [t0].[MoneyCardCashAmount], [t0].[MoneyCardHandselAmount], [t0].[PrepaymentAmount], [t0].[RegisterDate], [t15].[Name] AS [RegisterName], [t0].[Remark],
(CASE
WHEN [t1].[SceneEmployee] IS NOT NULL THEN CONVERT(NVarChar(MAX),[t16].[Name])
ELSE NULL
END) AS [SceneEmployee], [t0].[TotalPR],
(CASE
WHEN (CONVERT(Int,[t0].[UseDeviceID])) IS NOT NULL THEN [t17].[Name]
ELSE CONVERT(NVarChar(50),@p21)
END) AS [UseDevice], [t0].[YearCardAmount]
FROM [dbo].[ExcuteRecordTotal] AS [t0]
INNER JOIN [dbo].[CustomerBaseInfo] AS [t1] ON [t1].[ID] = [t0].[CustomerID]
LEFT OUTER JOIN [dbo].[MemberCardInfo] AS [t2] ON [t2].[CustomerID] = [t1].[ID]
INNER JOIN [dbo].[ItemInfo] AS [t3] ON [t3].[ID] = [t0].[ItemID]
LEFT OUTER JOIN [dbo].[Employee] AS [t4] ON [t4].[ID] = [t0].[AnesthetistID]
LEFT OUTER JOIN [dbo].[Employee] AS [t5] ON [t5].[ID] = [t0].[FirstAssistantID]
LEFT OUTER JOIN [dbo].[Employee] AS [t6] ON [t6].[ID] = [t0].[SecondAssistantID]
LEFT OUTER JOIN [dbo].[ExcuteInfo] AS [t7] ON [t7].[ID] = [t0].[ExcuteInfoID]
LEFT OUTER JOIN [dbo].[CustomerConsumptionDetails] AS [t8] ON [t8].[ID] = [t7].[CertainProjectID]
LEFT OUTER JOIN [dbo].[CustomerConsumptionInfo] AS [t9] ON [t9].[ExcutionNumber] = [t8].[ExcutionNumber]
INNER JOIN [dbo].[Department] AS [t10] ON [t10].[ID] = [t3].[ExcuteDepartmentID]
LEFT OUTER JOIN [dbo].[Employee] AS [t11] ON [t11].[ID] = [t0].[DoctorID]
LEFT OUTER JOIN [dbo].[ItemTypeInfo] AS [t12] ON [t12].[ID] = [t8].[ItemTypeID]
LEFT OUTER JOIN [dbo].[ItemCategory] AS [t13] ON [t13].[ID] = [t3].[TopCategoryID]
LEFT OUTER JOIN [dbo].[KindofSickness] AS [t14] ON [t14].[ID] = [t0].[KindofSicknessID]
INNER JOIN [dbo].[Employee] AS [t15] ON [t15].[ID] = [t0].[Registerby]
LEFT OUTER JOIN [dbo].[Employee] AS [t16] ON [t16].[ID] = [t1].[SceneEmployee]
LEFT OUTER JOIN [dbo].[Device] AS [t17] ON [t17].[ID] = [t0].[UseDeviceID]
WHERE ([t3].[TopCategoryID] IN (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10)) AND ([t0].[Date] >= @p11) AND ([t0].[Date] < @p12) AND ([t0].[Status] = @p13) AND ([t1].[Name] LIKE @p14) AND ([t0].[ExcuteInfoID] IS NOT NULL) AND ((
(CASE
WHEN @p15 = 1 THEN
(CASE
WHEN ([t2].[MemberCardNum] IS NOT NULL) AND ([t2].[MemberCardNum] LIKE @p16) THEN 1
WHEN NOT (([t2].[MemberCardNum] IS NOT NULL) AND ([t2].[MemberCardNum] LIKE @p16)) THEN 0
ELSE NULL
END)
WHEN [t2].[MemberCardNum] IS NOT NULL THEN CONVERT(Int,
(CASE
WHEN [t2].[MemberCardNum] LIKE @p17 THEN 1
WHEN NOT ([t2].[MemberCardNum] LIKE @p17) THEN 0
ELSE NULL
END))
ELSE @p18
END)) = 1) AND ([t0].[Registerby] <> @p19)',N'@p0 nvarchar(4000),@p1 nvarchar(4000),@p2 nvarchar(4000),@p3 nvarchar(4000),@p4 nvarchar(4000),@p5 nvarchar(4000),@p6 nvarchar(4000),@p7 nvarchar(4000),@p8 nvarchar(4000),@p9 nvarchar(4000),@p10 nvarchar(4000),@p11 datetime,@p12 datetime,@p13 int,@p14 nvarchar(4000),@p15 int,@p16 varchar(8000),@p17 varchar(8000),@p18 int,@p19 varchar(8000),@p20 nvarchar(4000),@p21 nvarchar(4000)',@p0=N'00001',@p1=N'00002',@p2=N'00003',@p3=N'00004',@p4=N'00005',@p5=N'00006',@p6=N'00007',@p7=N'00008',@p8=N'00009',@p9=N'00015',@p10=N'00027',@p11='2018-06-26 00:00:00',@p12='2018-06-28 00:00:00',@p13=0,@p14=N'%%',@p15=0,@p16='%%',@p17='%%',@p18=1,@p19='',@p20=N'',@p21=N''

select * from CountSettings

select * from Department

select * from ExcuteRecordTotal where CustomerID='7S1BLT8U48'

select * from ExcuteRecordTotal where ExcuteInfoID='255726'

select * from CustomerBaseInfo where Name like '%季桂霞%' 255726

select * from ExcuteRecordTotal where ID='255726'

select * from CustomerBaseInfo where ID='H4UMPSXCDO'

select * from ExcuteInfo where ID='255726'

delete from ExcuteRecordTotal where ID='344207'

select count(*) as cnt,ExcuteInfoID from ExcuteRecordTotal group by ExcuteInfoID having count(*)>1

select * from ExcuteRecordTotal where ExcuteInfoID='255731'

select * from CustomerBaseInfo where ID='PTSBCC7ITN'

select DoctorID,count(distinct(Date)) from ExcuteRecordTotal where Date>'2018-06-25' group by DoctorID having count(*)>0

select DoctorID,Date,* from ExcuteRecordTotal where Date>'2018-06-25'

select b.Name,c.Name,d.Name,* from ExcuteRecordTotal a
inner join ItemInfo b on a.ItemID=b.ID
inner join Employee c on a.DoctorID=c.ID
inner join CustomerBaseINfo d on a.CustomerID=d.ID
where a.Date>'2018-06-25' order by a.Date

select * from SQL_ExecuteInfo
exec sp_executesql N'SELECT [t0].[ID], [t0].[Address], [t0].[Age], [t0].[Amount], [t0].[Balance], [t0].[BirthDay], [t0].[ChannelEmployee], [t0].[CIdentity], [t0].[ComeTimes], [t0].[PresentationPeopleID], [t0].[ProfessionID], [t0].[RegionID], [t0].[CustomerServiceEmployee], [t0].[UnderstandWayID], [t0].[DoctorEmployee], [t0].[EducationID], [t0].[Email], [t0].[SceneEmployee], [t0].[TMKEmployee], [t0].[TempEmployee], [t0].[FirstPhone], [t0].[Forzen], [t0].[HasMedical], [t0].[HasSickHistory], [t0].[IntegrationBalance], [t0].[IsCome], [t0].[IsMember], [t0].[LastestOperateEmployee], [t0].[MSN], [t0].[Name], [t0].[NetChannelID], [t0].[OtherInfo], [t0].[PresentationInsideID], [t0].[PresentationMode], [t0].[PresentationOutsideID], [t0].[QQ], [t0].[RankID], [t0].[RegisterDate], [t0].[Remark], [t0].[Remove], [t0].[RowVersion], [t0].[SecondPhone], [t0].[Sex], [t0].[Status], [t0].[Success], [t0].[SuccessTimes], [t0].[ThirdPhone], [t0].[VIP], [t0].[ZipCode]
FROM [dbo].[CustomerBaseInfo] AS [t0]
WHERE [t0].[ID] = @p0',N'@p0 varchar(8000)',@p0='QNRQCV3Z43'

exec sp_executesql N'INSERT INTO [dbo].[ExcuteRecordTotal]([AnesthetistID], [ArrearsAmount], [CashAmount], [CategoryID], [CustomerID], [Date], [DoctorID], [EmployeeOne], [EmployeeTwo], [ExcuteInfoID], [ExcuteQuantity], [Excutetimes], [FirstAssistantID], [HandselItemModeID], [InsteadMoneyAmount], [IntegrationAmount], [ItemID], [ItemTypeID], [KindofSicknessID], [MoneyCardCashAmount], [MoneyCardHandselAmount], [MoneyCardPercent], [MoneyCardRealAmount], [MoneyCardTotalAmount], [OralExcuteInfoID], [OralExcuteStatus], [PackageID], [PrepaymentAmount], [Registerby], [RegisterDate], [Remark], [SceneEmployee], [SecondAssistantID], [Status], [TopCategoryID], [TotalOther], [TotalPR], [TotalRealMoney], [TreatmentStepID], [UseDeviceID], [YearCardAmount], [YearCardPercent], [YearCardRealAmount])
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15, @p16, @p17, @p18, @p19, @p20, @p21, @p22, @p23, @p24, @p25, @p26, @p27, @p28, @p29, @p30, @p31, @p32, @p33, @p34, @p35, @p36, @p37, @p38, @p39, @p40, @p41, @p42)

SELECT CONVERT(BigInt,SCOPE_IDENTITY()) AS [value]',N'@p0 varchar(8000),@p1 decimal(18,2),@p2 decimal(18,2),@p3 varchar(8000),@p4 varchar(8000),@p5 datetime,@p6 varchar(8000),@p7 varchar(8000),@p8 varchar(8000),@p9 bigint,@p10 decimal(18,2),@p11 smallint,@p12 varchar(8000),@p13 tinyint,@p14 decimal(18,2),@p15 decimal(18,2),@p16 varchar(8000),@p17 tinyint,@p18 smallint,@p19 decimal(18,2),@p20 decimal(18,2),@p21 decimal(7,6),@p22 decimal(18,2),@p23 decimal(18,2),@p24 bigint,@p25 tinyint,@p26 varchar(8000),@p27 decimal(18,2),@p28 varchar(8000),@p29 datetime,@p30 nvarchar(4000),@p31 varchar(8000),@p32 varchar(8000),@p33 tinyint,@p34 varchar(8000),@p35 decimal(18,2),@p36 decimal(18,2),@p37 decimal(18,2),@p38 bigint,@p39 smallint,@p40 decimal(18,2),@p41 decimal(7,6),@p42 decimal(18,2)',@p0=NULL,@p1=0,@p2=1800.00,@p3='00023',@p4='QNRQCV3Z43',@p5='2018-06-27 14:25:51.677',@p6='00003',@p7=NULL,@p8=NULL,@p9=255774,@p10=1.00,@p11=1,@p12=NULL,@p13=NULL,@p14=0,@p15=0,@p16='00620',@p17=0,@p18=6,@p19=0,@p20=0,@p21=0,@p22=0,@p23=0,@p24=NULL,@p25=NULL,@p26=NULL,@p27=0,@p28='00268',@p29='2018-06-27 14:26:31.570',@p30=N'tt',@p31='00006',@p32=NULL,@p33=0,@p34='00016',@p35=0,@p36=1800.00,@p37=1800.00,@p38=NULL,@p39=10,@p40=0,@p41=1.000000,@p42=0

exec sp_executesql N'SELECT COUNT(*) AS [value]
FROM [dbo].[CustomerForDepartment] AS [t0]
WHERE ([t0].[DepartmentID] = @p0) AND ([t0].[CustomerID] = @p1)',N'@p0 varchar(8000),@p1 varchar(8000)',@p0='003',@p1='QNRQCV3Z43'

select * from CustomerForDepartment where CustomerID='PTSBCC7ITN'

select * from ExcuteRecordTotal where remark is null

delete from ExcuteRecordTotal
where ExcuteInfoID in(
select ExcuteInfoID from ExcuteRecordTotal
group by ExcuteInfoID having count(ExcuteInfoID)>1
)
and Remark is null

select * from UpdateManage
update UpdateManage set NEW_VERSION='51'

select * from H_TMK_REC

select * from H_Project_Data

select * from bh20180529.dbo.ItemInfoID;

select ID SourceID ,Region as 来源地域,0 客人总数,0 成交总数, 0 初诊咨询数量,0 初诊成交数量,
0 复诊咨询数量,0 复诊成交数量,0 再消费成交数量,0 初诊收入数据,
0 复诊收入数据,0 再消费收入数据,0 其他收入,0 收入合计 from CustomerRegion

select count(*),cr.ID crid ,cr.Region crregion,sta.Status,suc.Success from CustomerRegion cr
inner join CustomerBaseInfo cbi on cbi.RegionID = cr.ID
inner join CustomerComeLog ccl on ccl.CustomerID=cbi.ID
inner join StatusOfCustomer sta on sta.CustomerID=cbi.ID
inner join SuccessOfCustomer suc on suc.CustomerID=cbi.ID
group by cr.ID, cr.Region,sta.Status,suc.Success

select * from UpdateManage

update UpdateManage set NEW_VERSION='55'

update bh20180529.dbo.CustomerPhoneNumber set PhoneNumber='13921652899' where PhoneNumber='13921652899男朋友'

select * from bh20180529.dbo.CustomerPhoneNumber where ISNUMERIC(PhoneNumber)=0

select top 100 * from consultingprojects where id='201683';

select top 100 * from consultinginfo a inner join consultingprojects b on a.ExcutionNumber=b.ExcutionNumber and b.ID='201683';

select * from CustomerPhoneNumber where PhoneNumber='17851372218'

select * from ReservationNumber where CustomerID='4592YZZP6O';

select sub.ID subID, sub.Name 部位, dept.ID deptID, dept.Name 部门, emp.ID empID, emp.Name 姓名,
sub.ContainsCategories, sub.ContainsConsultingCategories,
0 初诊上门量, 0 初诊成交量, 0 复诊上门量, 0 复诊成交量, 0 老顾客上门量,0 老顾客成交量
from CountSettingsForSubCategory sub, Employee emp, PositionInfo pos, Department dept
where sub.ID in(4,5,6,7,11) and dept.ID in (006,004,034)
and emp.Valid=1
and emp.PositionID=pos.ID
and pos.DepartmentID=dept.ID
order by sub.ID, dept.ID, emp.ID

select sta.Status,suc.Success, base.SceneEmployee, base.SceneEmployee,come.Date,base.UnderstandWayID,cuw.UnderstandWayName
from CustomerComeLog come
inner join CustomerBaseInfo base on base.ID = come.CustomerID
inner join CustomerUnderstandWay cuw on cuw.ID=base.UnderstandWayID
inner join StatusOfCustomer sta on sta.CustomerID=base.ID
inner join SuccessOfCustomer suc on suc.CustomerID=base.ID where sta.Status=4 and Date>'2018-06-29 00:00:00' and Date<'2018-06-30 00:00:00'

select * from CustomerUnderstandWay;

select ID uwayid,NetName 渠道类型, Valid 是否在用,'网络' as 来院类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from NetChannel cw where Valid=1 union
select ID uwayid, UnderstandWayName 渠道类型, 1 是否在用,'电话'as 来源类型,
0 客人总量, 0 成交总量, 0 初诊咨询总数, 0 初诊成交总数, 0 复诊咨询总数,0 复诊成交总数,
0 再消费人数,0 初诊收入,0 复诊收入,0 再消费业绩,0 其他收入 ,0 收入合计
from CustomerUnderstandWay cu order by 来院类型

select b.cls_Name from H_TMK_REC a inner join H_DeptSet b on a.sKS=b.KID

select c.sName,b.AName from H_TMK_REC a inner join H_Project_Data b on a.ProjectID=b.FID
inner join H_TMK c on c.FID=a.FID

select * from H_TMK;
select * from H_TMK_REC;

select * from H_DeptSet

select * from YUN_HIS20180622.dbo.H_TMK_ZX

select * from YUN_HIS20180622.dbo.H_Project_Data;

select a.FID,a.ProjectID,a.dDT,c.Now,d.Now from YUN_HIS20180622.dbo.H_TMK_ZX a
inner join YUN_HIS20180622.dbo.H_Project_Data b on a.ProjectID=b.FID
inner join bh20180529.dbo.ItemInfoID c on c.Original=b.KID
inner join bh20180529.dbo.CustomerBaseInfoID d on d.Original=a.FID
group by a.FID,a.ProjectID,c.Now,d.Now,a.dDT order by a.dDT

select top 100 * from CustomerComeLog

select * from CountSettings

group by ProjectID,FID,b.Now

select top 100 * from YUN_HIS20180622.dbo.H_Project_Data
select top 100 * from ItemInfoID
select top 100 * from YUN_HIS20180622.dbo.H_TMK_ZX

select * from ItemInfoID

select * from H_Project

select * from bh20180529.dbo.ItemInfoID

select * from H_Project_Data a inner join H_TMK b on a.FID=

select * from H_Project_Sort

select * from H_Project_Data