一代报告

时间:2011-06-11 11:30:24

标签: sql-server-2005

我正在做报告换班报告我有3个班次:

shift1 starts at 7am and ends at 3pm
shift2 starts at 3pm and ends at 11pm
shift3 starts at 11pm and ends at 7am

我必须根据班次生成报告。例如,如果用户从下拉列表中选择shift1,则报告应显示从早上7点到下午3点的所有数据。

我能够获取shift1和shift2的数据,但我无法获取shift3数据,因为 在shift3之后的12点,日期将会改变。

那么如何获取shift3的数据并根据这4个表中的日期获取数据

我的第一张表包含以下数据(shift3(11-7)):

Name       Shiftname     Operatorname  Date        plant    Line   Machine
---------  ------------  ------------  ----------  -------  -----  -------
Deepali    Shift3(11-7)  Operator 3    2011-06-07  Plant 1  Line1  mc1
Ashwini    Shift3(11-7)  Operator 3    2011-06-07  Plant 1  Line1  mc2
Antra      Shift3(11-7)  Operator 3    2011-06-07  Plant 1  Line2  mc3
Harshitha  Shift3(11-7)  Operator 3    2011-06-07  Plant 1  Line2  mc4
Pradeep    Shift3(11-7)  Operator 3    2011-06-07  Plant 2  Line3  mc5
Madhu      Shift3(11-7)  Operator 3    2011-06-07  Plant 2  Line3  mc6
Meena      Shift3(11-7)  Operator 3    2011-06-07  Plant 2  Line4  mc7
Suhas      Shift3(11-7)  Operator 3    2011-06-07  Plant 2  Line4  mc8

这是我的温度表(shift3(11-7)):

Temperature  Time                     Date
-----------  -----------------------  ----------
27           1900-01-01 23:34:56.000  2011-06-07
27.3         1900-01-01 23:36:56.000  2011-06-07
27.6         1900-01-01 23:38:56.000  2011-06-07
27.9         1900-01-01 23:40:56.000  2011-06-07
28.2         1900-01-01 23:42:56.000  2011-06-07
28.5         1900-01-01 23:44:55.000  2011-06-07
28.8         1900-01-01 23:46:55.000  2011-06-07
29.1         1900-01-01 23:48:55.000  2011-06-07
29.4         1900-01-01 23:50:55.000  2011-06-07
29.7         1900-01-01 23:52:55.000  2011-06-07
30           1900-01-01 23:54:55.000  2011-06-07
30           1900-01-01 23:56:55.000  2011-06-07
30.3         1900-01-01 23:58:55.000  2011-06-07
30.6         1900-01-01 00:00:55.000  2011-06-08
30.9         1900-01-01 00:02:55.000  2011-06-08
31.2         1900-01-01 00:04:55.000  2011-06-08
31.5         1900-01-01 00:06:55.000  2011-06-08
31.8         1900-01-01 00:08:55.000  2011-06-08
32.1         1900-01-01 00:10:55.000  2011-06-08
32.4         1900-01-01 00:12:55.000  2011-06-08
32.7         1900-01-01 00:14:55.000  2011-06-08
33           1900-01-01 00:16:55.000  2011-06-08
33.3         1900-01-01 00:18:55.000  2011-06-08
33.6         1900-01-01 00:20:55.000  2011-06-08
33.9         1900-01-01 00:22:55.000  2011-06-08
34.2         1900-01-01 00:24:55.000  2011-06-08
34.5         1900-01-01 00:26:55.000  2011-06-08
34.8         1900-01-01 00:28:55.000  2011-06-08
35.1         1900-01-01 00:30:55.000  2011-06-08
35.4         1900-01-01 00:32:55.000  2011-06-08
35.7         1900-01-01 00:34:55.000  2011-06-08
36           1900-01-01 00:36:55.000  2011-06-08
36.3         1900-01-01 00:38:55.000  2011-06-08
36.6         1900-01-01 00:40:55.000  2011-06-08
36.9         1900-01-01 00:42:55.000  2011-06-08
36.9         1900-01-01 00:44:55.000  2011-06-08
37.2         1900-01-01 00:46:55.000  2011-06-08
36.9         1900-01-01 00:48:55.000  2011-06-08
36.6         1900-01-01 00:50:55.000  2011-06-08
36.3         1900-01-01 00:52:55.000  2011-06-08
36           1900-01-01 00:54:55.000  2011-06-08
35.7         1900-01-01 00:56:55.000  2011-06-08
35.4         1900-01-01 00:58:55.000  2011-06-08
35.1         1900-01-01 01:00:55.000  2011-06-08
34.8         1900-01-01 01:02:55.000  2011-06-08
34.5         1900-01-01 01:04:55.000  2011-06-08
34.2         1900-01-01 01:06:55.000  2011-06-08
33.9         1900-01-01 01:08:55.000  2011-06-08
33.6         1900-01-01 01:10:55.000  2011-06-08
33.3         1900-01-01 01:12:55.000  2011-06-08
33           1900-01-01 01:14:55.000  2011-06-08
32.7         1900-01-01 01:16:55.000  2011-06-08
32.4         1900-01-01 01:18:55.000  2011-06-08
32.1         1900-01-01 01:20:55.000  2011-06-08
31.8         1900-01-01 01:22:55.000  2011-06-08
31.5         1900-01-01 01:24:55.000  2011-06-08
31.2         1900-01-01 01:26:55.000  2011-06-08
30.9         1900-01-01 01:28:55.000  2011-06-08
30.6         1900-01-01 01:30:55.000  2011-06-08
30.3         1900-01-01 01:32:56.000  2011-06-08
30           1900-01-01 01:34:55.000  2011-06-08
29.7         1900-01-01 01:36:56.000  2011-06-08
29.4         1900-01-01 01:38:55.000  2011-06-08
29.1         1900-01-01 01:40:55.000  2011-06-08
28.5         1900-01-01 03:03:02.000  2011-06-08
28.2         1900-01-01 03:05:02.000  2011-06-08
27.9         1900-01-01 03:07:02.000  2011-06-08
27.6         1900-01-01 03:09:02.000  2011-06-08
27.3         1900-01-01 03:11:02.000  2011-06-08
27           1900-01-01 03:13:02.000  2011-06-08
27           1900-01-01 03:15:02.000  2011-06-08
27           1900-01-01 03:17:02.000  2011-06-08
27           1900-01-01 03:19:02.000  2011-06-08
27           1900-01-01 03:21:03.000  2011-06-08
27           1900-01-01 03:23:02.000  2011-06-08
27           1900-01-01 03:25:02.000  2011-06-08
27           1900-01-01 03:27:02.000  2011-06-08
27           1900-01-01 03:29:02.000  2011-06-08
27           1900-01-01 04:33:06.000  2011-06-08
27.3         1900-01-01 04:35:07.000  2011-06-08
27.6         1900-01-01 04:37:06.000  2011-06-08
27.9         1900-01-01 04:39:07.000  2011-06-08
28.2         1900-01-01 04:41:06.000  2011-06-08
28.5         1900-01-01 04:43:06.000  2011-06-08
28.8         1900-01-01 04:45:06.000  2011-06-08
29.1         1900-01-01 04:47:07.000  2011-06-08
29.4         1900-01-01 04:49:06.000  2011-06-08
29.7         1900-01-01 04:51:06.000  2011-06-08
29.7         1900-01-01 04:53:06.000  2011-06-08
30           1900-01-01 04:55:06.000  2011-06-08
30.3         1900-01-01 04:57:06.000  2011-06-08
30.6         1900-01-01 04:59:07.000  2011-06-08
27           1900-01-01 05:33:04.000  2011-06-08
27.3         1900-01-01 05:35:04.000  2011-06-08
27.6         1900-01-01 05:37:04.000  2011-06-08
27.9         1900-01-01 05:39:04.000  2011-06-08
28.2         1900-01-01 05:41:04.000  2011-06-08
28.5         1900-01-01 05:43:04.000  2011-06-08
28.8         1900-01-01 05:45:04.000  2011-06-08
29.1         1900-01-01 05:47:04.000  2011-06-08
29.4         1900-01-01 05:49:04.000  2011-06-08
29.7         1900-01-01 05:51:04.000  2011-06-08
29.7         1900-01-01 05:53:04.000  2011-06-08
30           1900-01-01 05:55:04.000  2011-06-08
30.3         1900-01-01 05:57:04.000  2011-06-08
30.6         1900-01-01 05:59:04.000  2011-06-08

压力和pH相同,只有压力柱和ph柱值会改变。

我在数据库中存储数据,有4个表,日期是我的主要关键。 我必须根据日期链接这些数据。

我在gridview中显示数据。

我希望我的输出像这样:

Temperature  Time                     Date        Pressure
-----------  -----------------------  ----------  --------
27           1900-01-01 23:34:56.000  2011-06-07  30
27.3         1900-01-01 23:36:56.000  2011-06-07  30.1
27.6         1900-01-01 23:38:56.000  2011-06-07  30.2
27.9         1900-01-01 23:40:56.000  2011-06-07  30.3
28.2         1900-01-01 23:42:56.000  2011-06-07  30.4
28.5         1900-01-01 23:44:55.000  2011-06-07  30.5
28.8         1900-01-01 23:46:55.000  2011-06-07  30.6
29.1         1900-01-01 23:48:55.000  2011-06-07    .
29.4         1900-01-01 23:50:55.000  2011-06-07    .
29.7         1900-01-01 23:52:55.000  2011-06-07    .
30           1900-01-01 23:54:55.000  2011-06-07    .
30           1900-01-01 23:56:55.000  2011-06-07    .
30.3         1900-01-01 23:58:55.000  2011-06-07 
30.6         1900-01-01 00:00:55.000  2011-06-08 
30.9         1900-01-01 00:02:55.000  2011-06-08 
31.2         1900-01-01 00:04:55.000  2011-06-08 
31.5         1900-01-01 00:06:55.000  2011-06-08 
31.8         1900-01-01 00:08:55.000  2011-06-08 
32.1         1900-01-01 00:10:55.000  2011-06-08 
32.4         1900-01-01 00:12:55.000  2011-06-08 
32.7         1900-01-01 00:14:55.000  2011-06-08 
33           1900-01-01 00:16:55.000  2011-06-08 
33.3         1900-01-01 00:18:55.000  2011-06-08 
33.6         1900-01-01 00:20:55.000  2011-06-08 
33.9         1900-01-01 00:22:55.000  2011-06-08 
34.2         1900-01-01 00:24:55.000  2011-06-08 
34.5         1900-01-01 00:26:55.000  2011-06-08 
34.8         1900-01-01 00:28:55.000  2011-06-08 
35.1         1900-01-01 00:30:55.000  2011-06-08 
35.4         1900-01-01 00:32:55.000  2011-06-08 
35.7         1900-01-01 00:34:55.000  2011-06-08 
36           1900-01-01 00:36:55.000  2011-06-08 
36.3         1900-01-01 00:38:55.000  2011-06-08 
36.6         1900-01-01 00:40:55.000  2011-06-08 
36.9         1900-01-01 00:42:55.000  2011-06-08 
36.9         1900-01-01 00:44:55.000  2011-06-08 
37.2         1900-01-01 00:46:55.000  2011-06-08 
36.9         1900-01-01 00:48:55.000  2011-06-08 
36.6         1900-01-01 00:50:55.000  2011-06-08 
36.3         1900-01-01 00:52:55.000  2011-06-08 
36           1900-01-01 00:54:55.000  2011-06-08 
35.7         1900-01-01 00:56:55.000  2011-06-08 
35.4         1900-01-01 00:58:55.000  2011-06-08 
35.1         1900-01-01 01:00:55.000  2011-06-08 
34.8         1900-01-01 01:02:55.000  2011-06-08 
34.5         1900-01-01 01:04:55.000  2011-06-08 
34.2         1900-01-01 01:06:55.000  2011-06-08 
33.9         1900-01-01 01:08:55.000  2011-06-08 
33.6         1900-01-01 01:10:55.000  2011-06-08 
33.3         1900-01-01 01:12:55.000  2011-06-08 
33           1900-01-01 01:14:55.000  2011-06-08 
32.7         1900-01-01 01:16:55.000  2011-06-08 
32.4         1900-01-01 01:18:55.000  2011-06-08 
32.1         1900-01-01 01:20:55.000  2011-06-08 
31.8         1900-01-01 01:22:55.000  2011-06-08 
31.5         1900-01-01 01:24:55.000  2011-06-08 
31.2         1900-01-01 01:26:55.000  2011-06-08 
30.9         1900-01-01 01:28:55.000  2011-06-08 
30.6         1900-01-01 01:30:55.000  2011-06-08 
30.3         1900-01-01 01:32:56.000  2011-06-08 
30           1900-01-01 01:34:55.000  2011-06-08 
29.7         1900-01-01 01:36:56.000  2011-06-08 
29.4         1900-01-01 01:38:55.000  2011-06-08 
29.1         1900-01-01 01:40:55.000  2011-06-08 
28.5         1900-01-01 03:03:02.000  2011-06-08 
28.2         1900-01-01 03:05:02.000  2011-06-08 
27.9         1900-01-01 03:07:02.000  2011-06-08 
27.6         1900-01-01 03:09:02.000  2011-06-08 
27.3         1900-01-01 03:11:02.000  2011-06-08 
27           1900-01-01 03:13:02.000  2011-06-08 
27           1900-01-01 03:15:02.000  2011-06-08 
27           1900-01-01 03:17:02.000  2011-06-08 
27           1900-01-01 03:19:02.000  2011-06-08 
27           1900-01-01 03:21:03.000  2011-06-08 
27           1900-01-01 03:23:02.000  2011-06-08
27           1900-01-01 03:25:02.000  2011-06-08 
27           1900-01-01 03:27:02.000  2011-06-08 
27           1900-01-01 03:29:02.000  2011-06-08 
27           1900-01-01 04:33:06.000  2011-06-08 
27.3         1900-01-01 04:35:07.000  2011-06-08 
27.6         1900-01-01 04:37:06.000  2011-06-08 
27.9         1900-01-01 04:39:07.000  2011-06-08 
28.2         1900-01-01 04:41:06.000  2011-06-08 
28.5         1900-01-01 04:43:06.000  2011-06-08 
28.8         1900-01-01 04:45:06.000  2011-06-08 
29.1         1900-01-01 04:47:07.000  2011-06-08 
29.4         1900-01-01 04:49:06.000  2011-06-08 
29.7         1900-01-01 04:51:06.000  2011-06-08 
29.7         1900-01-01 04:53:06.000  2011-06-08 
30           1900-01-01 04:55:06.000  2011-06-08 
30.3         1900-01-01 04:57:06.000  2011-06-08 
30.6         1900-01-01 04:59:07.000  2011-06-08 
27           1900-01-01 05:33:04.000  2011-06-08 
27.3         1900-01-01 05:35:04.000  2011-06-08 
27.6         1900-01-01 05:37:04.000  2011-06-08 
27.9         1900-01-01 05:39:04.000  2011-06-08 
28.2         1900-01-01 05:41:04.000  2011-06-08 
28.5         1900-01-01 05:43:04.000  2011-06-08 
28.8         1900-01-01 05:45:04.000  2011-06-08 
29.1         1900-01-01 05:47:04.000  2011-06-08 
29.4         1900-01-01 05:49:04.000  2011-06-08 
29.7         1900-01-01 05:51:04.000  2011-06-08 
29.7         1900-01-01 05:53:04.000  2011-06-08 
30           1900-01-01 05:55:04.000  2011-06-08 
30.3         1900-01-01 05:57:04.000  2011-06-08
30.6         1900-01-01 05:59:04.000  2011-06-08    .

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

你需要找出要求 - 当有人选择第3班和日期时,他们可能意味着3件不同的事情:

  • 报告从该日开始的班次3。

  • 关于在该日期结束的班次3的报告。

  • 报告该日从午夜到早上7点和11点到午夜3点班次。

如果人们真的按日期收到报告,那么我希望他们会想要最后一份报告。