下午问过一次 可能没说清楚 没得到好的答案 现在重新开贴问一次
ALTER FUNCTION [dbo].[GetHistory]
(
@IssueNum int,@Name varchar(100),@NumSum int,@Result varchar(50),@History varchar(100)
)
RETURNS varchar(1024)
AS
BEGIN
DECLARE @tempID int
select top 1 @tempID=IssueNum from NumsData where IssueNum<@IssueNum and [Name][email protected] and NumSum [email protected] and [email protected] and [email protected] order by IssueNum desc
set @History=''
if @tempID>0
begin
select top 3 @[email protected]+R1 from NumsData where IssueNum<[email protected] and [Name][email protected] order by IssueNum desc
end
return @History
END
比如 编号是118的数据 根据这个条件IssueNum<@IssueNum and [Name][email protected] and NumSum [email protected] and [email protected] and [email protected] order by IssueNum desc
搜索到了一条编号为089的数据
[email protected][email protected]+R1 也就是返回的是 118 117 116的R1的值
而我需要得到的返回值是089后面三条数据 也就是090 091 092 三条数据R1字段的值
比如三个值分别是 好 孬 好
[email protected]:好孬好 这样一个数据
------解决方案--------------------
- SQL code
--看下是不是你要的结果select top 3 @[email protected]+R1 from NumsData where IssueNum>@tempID and [Name][email protected] order by IssueNum asc
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
刚才想了想这个思路不对!!!inner join的应该是后三个连续的编号,而我判断的他是否三个连续的编号!!
不应该是inner Join !!方便留下QQ吗?帮你解决一下,这样回复太慢了