易截截图软件、单文件、免安装、纯绿色、仅160KB

关于SQL的问题? - MS-SQL Server / 基础类

Id Name Flag
1 张三 1  
2 王五 3
3 张三 1
4 李四 2
5 张三 1
6 李四 2

我想输出的时候变成这样

Id Name Flag
1 张三 1  
3 张三 1
5 张三 1
4 李四 2
6 李四 2
2 王五 2

SQL如何写? 

注:只分组不统计


SQL code:
select * from [TB] order by Flag



?

假如Flag是文本呢 ?

引用
假如Flag是文本呢 ?

select * from tb order by cast(Flag as int)

o

SQL code:
--sinpoal

if object_id ('ta' ) is not null drop table ta
create table ta(id int ,[name] char(8), flag int)
insert into ta
select 1,'张三',1 union all
select 2,'王五',3 union all
select 3,'张三',1 union all
select 4,'李四',2 union all
select 5,'张三',1 union all
select 6,'李四',2


select * from ta order by flag


/*-----------RESULT-----------
id name flag
1 张三 1
3 张三 1
5 张三 1
6 李四 2
4 李四 2
2 王五 3
*/



SQL code



Code highlighting produced by


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

数据窗口动态修改Sql - PowerBuilder / DataWindow

为了满足数据查询的速度问题,我将一张数据量大的学生表按年度分成多个表
students_2008, students_2009然后我又做了一个模板表students_template,模板表中的字段和students_2008, students_2009一样,只不过是一个 ......

sql 存储过程

我要做一个定点事件,是每天晚上12点就把三个表里的信息放入一个表里,我想用存储过程来写,怎么写呢?,那位高手帮帮忙吧,非常感谢!

用户名是唯一的
表A  字段
用户名:Name  ,邮箱:Ema ......

sql 函数问题 - MS-SQL Server / 应用实例

sql我想得到一字符串为:
sldkf|||sdeww
erkv|||rltdk
jemcl|||ligf
就是|||后面的字符有什么函数能得到吗?是在sql语句写的,不是在页面写的,那位高手来指教下,新手,谢谢
晕今天不是写了么

select parsen ......

求一条SQL - MS-SQL Server / 疑难问题

--drop table #T1
--drop table #T2
create Table #T1(ID int,
QueryID nvarchar(20),
ResultID1 nvarchar(20),
ResultID2 nvarchar(20))
create Table #T2(SortNo int,
QueryID nvarchar(20),
ResultID1 nv ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号