DECLARE @Bigger INT,@Mid INT,@Small INT
SET @Bigger = 0
WHILE @Bigger <= 100
BEGIN
SET @Mid = 0
WHILE @Mid <= 100 -@Bigger
BEGIN
SELECT @Small = 100 -@Bigger - @Mid;
IF @Bigger * 3 + @Mid * 2 + @Small * 0.5 = 100
BEGIN
SELECT @Bigger AS Big ,@Mid AS Mid,@Small AS Small
END
SELECT @Mid += 1;
END
SELECT @Bigger += 1;
END
使用SQL SERVER 的方法
Big Mid Small
----------- ----------- -----------
2 30 68
(1 個資料列受到影響)
Big Mid Small
----------- ----------- -----------
5 25 70
(1 個資料列受到影響)
Big Mid Small
----------- ----------- -----------
8 20 72
(1 個資料列受到影響)
Big Mid Small
----------- ----------- -----------
11 15 74
(1 個資料列受到影響)
Big Mid Small
----------- ----------- -----------
14 10 76
(1 個資料列受到影響)
Big Mid Small
----------- ----------- -----------
17 5 78
(1 個資料列受到影響)
Big Mid Small
----------- ----------- -----------
20 0 80
(1 個資料列受到影響) |