declare @a table(A int) insert @a select 29 union all select 31 union all select 35 union all select 49 union all select 51 union all select 61 union all select 81 union all select 97 union all select 133 select a % 17 b,a from @a order by b select a % 17 b,a into #tmp from @a order by b,a select a,省的顺序=(select count(1) from #tmp where b<=c.b) from #tmp c drop table #tmp
1 select *,'1开'+cast(floor(规格尺寸/17) as varchar(10)) as 可开料 from 表2 select top 1 * from 表 order by 规格尺寸 % 17
2如果最省的有多个,要一起查出select * from 表 where 规格尺寸 % 17=(select min(规格尺寸 % 17) from 表)
1 select *,'1开'+rtrim(规格尺寸/17) 可开料 from 表2 select top 1 * from 表 order by (规格尺寸 % 17)/(规格尺寸/17)
规格尺寸都为int时 相除只保留整数位 最省应该是余料 除以 开数
最省应该是余料 除以 开数如果最省的有多个,要一起查出select * from 表 where 1.0*(规格尺寸 % 17)/floor(规格尺寸/17)=(select min(1.0*(规格尺寸 % 17)/floor(规格尺寸/17)) from 表)
declare @a table(A int) insert @a select 29 union all select 31 union all select 35 union all select 49 union all select 51 union all select 61 union all select 81 union all select 97 union all select 133select A as b from @f order by (A%17) 这样不可以????
declare @a table(A int) insert @a select 29 union all select 31 union all select 35 union all select 49 union all select 51 union all select 61 union all select 81 union all select 97 union all select 133select top 1 A from @f order by (A%17),A/17先考虑余数,在考虑开数,取第一个! 感觉大家考虑的太多!!看问题复杂化拉!
insert @a select 29
union all select 31
union all select 35
union all select 49
union all select 51
union all select 61
union all select 81
union all select 97
union all select 133
select a % 17 b,a from @a order by b
select a % 17 b,a into #tmp from @a order by b,a
select a,省的顺序=(select count(1) from #tmp where b<=c.b) from #tmp c
drop table #tmp
select *,'1开'+cast(floor(规格尺寸/17) as varchar(10)) as 可开料 from 表2
select top 1 * from 表
order by 规格尺寸 % 17
where 规格尺寸 % 17=(select min(规格尺寸 % 17) from 表)
select *,'1开'+rtrim(规格尺寸/17) 可开料 from 表2
select top 1 * from 表
order by (规格尺寸 % 17)/(规格尺寸/17)
最省应该是余料 除以 开数
where 1.0*(规格尺寸 % 17)/floor(规格尺寸/17)=(select min(1.0*(规格尺寸 % 17)/floor(规格尺寸/17)) from 表)
insert @a select 29
union all select 31
union all select 35
union all select 49
union all select 51
union all select 61
union all select 81
union all select 97
union all select 133select A as b from @f order by (A%17)
这样不可以????
insert @a select 29
union all select 31
union all select 35
union all select 49
union all select 51
union all select 61
union all select 81
union all select 97
union all select 133select top 1 A from @f order by (A%17),A/17先考虑余数,在考虑开数,取第一个!
感觉大家考虑的太多!!看问题复杂化拉!
(A%17),A/17 都是整数(A%17)/(A/17)也是整数操作,参考冒牌的答案
1开1耗料最少的
1开2耗料最少的
1开3耗料最少的
::请虎虎,冒牌再出手。TKS!
where not exists(select 1 from 表 where 规格尺寸/17=A.规格尺寸/17 and 规格尺寸%17<A.规格尺寸%17)