哥们,你的a1,a2是结果还是column。详细些。
解决方案 »
- 请教一个TSQL写法,想在查询的时候同时统计记录个数
- 计算标量与top的先后次序问题请教
- 存储过程查询现有表中是否存在相同字段,如果有,则将该相同的字段返回。。得到不到结果。。昏
- 在SQL Server2000中怎样取得一个datetime类型的数据的time值?
- Windows 2000 advaced server 安装sql server enterprise 失败
- win2000 server 上装不了sql2000??????
- 紧急求助:sql server 2000数据同步问题求高手赐教
- 请问怎么清除数据库的日志文件????我的已经有快4G了。
- 在线等待,小问题
- 很久没有来CSDN了,有一急问题,用了聚合函数,查询太慢
- 更新数据时,可否实现动态的约束或规则?
- 写一个Sql 语句
select a=a1+','+a2+','+a3,b from t group by a1+','+a2+','+a3,b
CASE WHEN a.fScore IS NULL THEN NULL
ELSE COUNT(b.fScore) + 1 END AS nPlace,
a.fScore_All,a.fScore,
a.fScoreLost,a.fScoreRatio,
a.fScoreLostRatio
FROM dbo.vScore_Year_Type a LEFT OUTER JOIN
dbo.vScore_Year_Type b ON
a.nYear =b.nYear AND
a.nMainBussinessID =b.nMainBussinessID
AND a.fScore < b.fScore
GROUP BY a.strAreaID,a.nYear,
a.nMainBussinessID,
a.strMainBussinessName,a.fScore_All,
a.fScore,a.fScoreLost,
a.fScoreRatio,a.fScoreLostRatio
ORDER BY a.nYear,a.nMainBussinessID,
CASE WHEN a.fScore IS NULL THEN NULL
ELSE COUNT(b.fScore) + 1 END但现在对字符串进行处理,不知怎么办了?
SELECT *
FROM (SELECT a1 + ',' + a2 + ',' + a3 as a ,b FROM t) as table1
GROUP BY table1.a , table1.b
SELECT *
FROM (SELECT a1 + ',' + a2 + ',' + a3 as a ,b FROM t) as table1
GROUP BY table1.a , table1.b
@res varchar (1024) output
as-- Declare the variables to store the values returned by FETCH.
DECLARE @a varchar(40)
DECLARE test_cursor CURSOR FOR
SELECT a FROM test
group by a,b
OPEN test_cursor-- Perform the first fetch and store the values in variables.
-- Note: The variables are in the same order as the columns
-- in the SELECT statement. FETCH NEXT FROM test_cursor
INTO @a-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN -- Concatenate and display the current values in the variables.
--PRINT "Author: " + @au_fname + " " + @au_lname
set @res = @res + rtrim(@a) + ','
-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM test_cursor
INTO @a
END
print @resCLOSE test_cursor
DEALLOCATE test_cursorreturn