首页 新闻 会员 周边

C#中按条件的合同匹配

0
悬赏园豆:30 [已解决问题] 解决于 2015-09-09 20:44

题目大概就是这样子的。题目有点长,希望先好好看看题目

ouyangdu的主页 ouyangdu | 初学一级 | 园豆:6
提问于:2015-09-08 10:55
< >
分享
最佳答案
0

用SQL写了个不知道是不是你要的,下面这个是用来测试的脚本:

 1 USE [TestDB]
 2 GO
 3 /****** Object:  Table [dbo].[Overdue]    Script Date: 09/09/2015 15:35:13 ******/
 4 SET ANSI_NULLS ON
 5 GO
 6 SET QUOTED_IDENTIFIER ON
 7 GO
 8 --逾期表
 9 CREATE TABLE [dbo].[Overdue](
10     [Contract] [nchar](10) NULL,
11     [Stores] [nchar](10) NULL,
12     [Product] [nchar](10) NULL,
13     [OverdueLevel] [nchar](10) NULL
14 ) ON [PRIMARY]
15 GO
16 INSERT [dbo].[Overdue] ([Contract], [Stores], [Product], [OverdueLevel]) VALUES (N'012       ', N'001       ', N'01        ', N'1         ')
17 INSERT [dbo].[Overdue] ([Contract], [Stores], [Product], [OverdueLevel]) VALUES (N'224       ', N'001       ', N'01        ', N'2         ')
18 INSERT [dbo].[Overdue] ([Contract], [Stores], [Product], [OverdueLevel]) VALUES (N'031       ', N'001       ', N'01        ', N'1         ')
19 INSERT [dbo].[Overdue] ([Contract], [Stores], [Product], [OverdueLevel]) VALUES (N'094       ', N'002       ', N'01        ', N'2         ')
20 INSERT [dbo].[Overdue] ([Contract], [Stores], [Product], [OverdueLevel]) VALUES (N'095       ', N'003       ', N'02        ', N'3         ')
21 INSERT [dbo].[Overdue] ([Contract], [Stores], [Product], [OverdueLevel]) VALUES (N'066       ', N'004       ', N'03        ', N'4         ')
22 INSERT [dbo].[Overdue] ([Contract], [Stores], [Product], [OverdueLevel]) VALUES (N'077       ', N'001       ', N'01        ', N'1         ')
23 /****** Object:  Table [dbo].[ContractInPersonnel]    Script Date: 09/09/2015 15:35:13 ******/
24 SET ANSI_NULLS ON
25 GO
26 SET QUOTED_IDENTIFIER ON
27 GO
28 --表C (關聯表)
29 CREATE TABLE [dbo].[ContractInPersonnel](
30     [Contract] [nchar](10) NULL,
31     [Personnel] [nchar](10) NULL
32 ) ON [PRIMARY]
33 GO
34 /****** Object:  Table [dbo].[CollectionPersonnel]    Script Date: 09/09/2015 15:35:13 ******/
35 SET ANSI_NULLS ON
36 GO
37 SET QUOTED_IDENTIFIER ON
38 GO
39 --催收人員表
40 CREATE TABLE [dbo].[CollectionPersonnel](
41     [Personnel] [nchar](10) NULL,
42     [Stores] [nchar](10) NULL,
43     [Product] [nchar](10) NULL,
44     [OverdueLevel] [nchar](10) NULL
45 ) ON [PRIMARY]
46 GO
47 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'101       ', N'001       ', N'01        ', N'1         ')
48 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'302       ', N'001       ', N'01        ', N'1         ')
49 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'503       ', N'002       ', N'02        ', N'2         ')
50 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'104       ', N'003       ', N'02        ', N'3         ')
51 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'705       ', N'004       ', N'03        ', N'4         ')
52 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'906       ', N'001       ', N'01        ', N'2         ')
53 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'407       ', N'001       ', N'02        ', N'3         ')
54 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'208       ', N'002       ', N'01        ', N'2         ')
55 INSERT [dbo].[CollectionPersonnel] ([Personnel], [Stores], [Product], [OverdueLevel]) VALUES (N'909       ', N'001       ', N'01        ', N'2         ')
View Code

下面这个是实现的语句:

View Code

看注释应该能看明白吧

补个执行结果给你吧:

收获园豆:30
明Lam | 小虾三级 |园豆:615 | 2015-09-09 15:44

谢谢,最后那个不能平均分配是随机分配就好了

ouyangdu | 园豆:6 (初学一级) | 2015-09-09 20:43
其他回答(1)
0

没明白你的意思。

 

你应该举例  A数据、B数据,期望的C数据

519740105 | 园豆:5810 (大侠五级) | 2015-09-08 11:14

我把题目改了,你在看看

支持(0) 反对(0) ouyangdu | 园豆:6 (初学一级) | 2015-09-08 11:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册