我正在尝试一次获取更多数据,以便将这些数据导出到文档中。 所以我想使用distinct来减少数据,然后想要用这些来获取列。
DECLARE @counter INT,
@loop INT,
@company_name VARCHAR(40)
SET @counter = 10,
@loop = 0
WHILE @loop <= @counter
SELECT Company, Firstname, Surname, eMail, Adress, Place, Phone, Fax FROM `table`
WHERE Company = PRINT @company_name
BEGIN SET @counter = (
SELECT COUNT (SET @company_name = (
SELECT DISTINCT Company FROM `table`
)) FROM `table`
)
SET @loop = @loop +1
END
答案 0 :(得分:1)
我认为您需要设置循环而不是计数器
SET @loop = @loop +1
而不是
SET @counter = @counter +1