SQL CASE的用法,比想象中的强大
表如下
一条语句显示所有大于25岁和下的人,以上的人显'大龄'
select case when age>25 then '大龄' else '小龄' end as 年龄级别,count(*) as 人数 from infor group by case when age>25 then '大龄' else '小龄' end
相关文档:
table a(id, type):
id type
----------------------------------
1 1
2 1
3 &n ......
不知道这样的要求能不能实现?
比如我有一张表T1,里面只有一个字段1
里面有100条记录,如下所示:
字段1
A1
A2
A3
A4
...
A100
我想用一条SQL显示这样的结果
第一列 第二列 ... 第十列
A1 A11 &nb ......
---SQL实现完全排列组合
create function F_strSpit(@s varchar(200)) returns table
as
return(
select value=substring(@s,i,num)+substring(@s,num-1+j,1)
from (select num=number from spt_values where type='p' and number<len(@s) and number>0)TA,
(select i=number+1 from spt_values where type='p ......
方法一:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),\'-\',\'\'),\' \',\'\'),\':\',\'\')
20040912110608 h
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 11 ......
using System.Data.SqlClient;
using System.Data.OleDb;
private void tsmiImportTeacherInfo_Click(object sender, EventArgs e)
{
DataSet ds;
  ......