- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
SELECT ISNULL(SUM(dbo.colors.setup_time_base + dbo.colors.setup_time_add), 0) AS setup_time, ISNULL(SUM(dbo.colors.setup_time_base), 0) AS setup_time_base,
ISNULL(SUM(dbo.colors.setup_time_add), 0) AS setup_time_add, ISNULL(SUM(dbo.colors.setup_length_base), 0) + 40 AS setup_lenght_base,
ISNULL(SUM(dbo.colors.setup_lenght_add), 0) AS setup_lenght_add, ISNULL(SUM(dbo.colors.setup_length_base + dbo.colors.setup_lenght_add), 0)
+ 40 AS setup_lenght, ISNULL(COUNT(dbo.dir_order_sections.color_id), 0) AS section_count, CASE WHEN COUNT(dbo.dir_order_sections.color_id)
= 0 THEN 0.5 WHEN COUNT(dbo.dir_order_sections.color_id) >= 1 AND COUNT(dbo.dir_order_sections.color_id)
<= 2 THEN 0.65 WHEN COUNT(dbo.dir_order_sections.color_id) >= 3 AND COUNT(dbo.dir_order_sections.color_id)
<= 6 THEN 1 WHEN COUNT(dbo.dir_order_sections.color_id) >= 7 AND COUNT(dbo.dir_order_sections.color_id)
<= 10 THEN 1.15 WHEN COUNT(dbo.dir_order_sections.color_id) >= 11 THEN 1.3 ELSE 0 END AS section_rate, CASE WHEN COUNT(dbo.dir_order_sections.color_id)
= 0 THEN 0.03 WHEN COUNT(dbo.dir_order_sections.color_id) >= 1 AND COUNT(dbo.dir_order_sections.color_id)
<= 2 THEN 0.04 WHEN COUNT(dbo.dir_order_sections.color_id) >= 3 AND COUNT(dbo.dir_order_sections.color_id)
<= 7 THEN 0.05 WHEN COUNT(dbo.dir_order_sections.color_id) >= 8 AND COUNT(dbo.dir_order_sections.color_id)
<= 10 THEN 0.07 WHEN COUNT(dbo.dir_order_sections.color_id) >= 11 THEN 0.07 ELSE 0 END AS role_rate, CASE WHEN COUNT(dbo.dir_order_sections.color_id)
= 0 THEN 0.03 WHEN COUNT(dbo.dir_order_sections.color_id) >= 1 AND COUNT(dbo.dir_order_sections.color_id)
<= 2 THEN 0.04 WHEN COUNT(dbo.dir_order_sections.color_id) >= 3 AND COUNT(dbo.dir_order_sections.color_id)
<= 7 THEN 0.05 WHEN COUNT(dbo.dir_order_sections.color_id) >= 8 AND COUNT(dbo.dir_order_sections.color_id)
<= 10 THEN 0.07 WHEN COUNT(dbo.dir_order_sections.color_id) >= 11 THEN 0.07 ELSE 0 END AS role_shift_rate_base, ISNULL(SUM(dbo.colors.role_shift_rate_add),
0) + CASE WHEN COUNT(dbo.dir_order_sections.color_id) = 0 THEN 0.03 WHEN COUNT(dbo.dir_order_sections.color_id) >= 1 AND
COUNT(dbo.dir_order_sections.color_id) <= 2 THEN 0.04 WHEN COUNT(dbo.dir_order_sections.color_id) >= 3 AND COUNT(dbo.dir_order_sections.color_id)
<= 7 THEN 0.05 WHEN COUNT(dbo.dir_order_sections.color_id) >= 8 AND COUNT(dbo.dir_order_sections.color_id)
<= 9 THEN 0.06 WHEN COUNT(dbo.dir_order_sections.color_id) >= 10 THEN 0.07 ELSE 0 END AS role_shift_rate, dbo.orders.order_n
FROM dbo.orders LEFT OUTER JOIN
dbo.dir_order_sections ON dbo.dir_order_sections.order_n = dbo.orders.order_n AND dbo.dir_order_sections.color_id <> 0 AND
dbo.dir_order_sections.color_id IS NOT NULL LEFT OUTER JOIN
dbo.colors ON dbo.dir_order_sections.color_id = dbo.colors.color_id
GROUP BY dbo.orders.order_n
eth0 15.07.2012 16:26 # +2
bormand 15.07.2012 19:16 # 0
TarasB 15.07.2012 19:48 # 0
bormand 15.07.2012 19:51 # 0
someone 15.07.2012 20:38 # 0
Это приложение WinForms с многолетней историей, прикрученное к жутко ынтырпрайзной базе MSSQL на 280 таблиц и 160 вью.
Половина всей расчётной логики запихана в stored-процедуры и вот такие вот простыни-вью. В итоге, чтобы выполнить расчёт, приложение подцепляется к базе и передаёт ей параметры расчёта.
Половину кода на C# тоже можно на ГК отправлять. В общем, стандартно для такого вот динозавра, разросшегося органически за годы.