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

求 sql语句 - MS-SQL Server / 基础类


表1: actornum name add
  1 liu csdn
  2 li sina
  3 wei baidu


表2: studentnum sex birthday idnum
  123 男 19890402 51010211110000
  234 女 19880000 52222312321544

表1 和表2 是两个毫不相干的表 现在我想要把表1中的name 字段和表2的birthday字段分列显示到一个查询结果集中 该用什么样的select语句?

就是说我要得到如下的结果:
name birthday  
liu 19890402  
li 19880000  
wei
弄个序号关联一下

SQL code:
select a.name,isnull(b.birthday ,'') as birthday
from 表1 a left join (select *,rn=row_number() over(order by getdate()) 表2 )b on a.actornum=b.rn


顶独眼龙

独眼龙的代码看不懂 能否解释下?

SQL code:
select
a.name,isnull(b.birthday ,'') as birthday---这里简单 取字段
from
表1 a
left join
(select *,rn=row_number() over(order by getdate()) 表2 )b ---为b加个排序列 与 表1关联
on
a.actornum=b.rn -------关联条件

{{


相关问答:

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如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

数据以xml格式返回 - MS-SQL Server / 应用实例

从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
   <folder state="unchecked&qu ......

求一个SQL语句 - MS-SQL Server / 基础类

字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......

求一SQL写法 - MS-SQL Server / 基础类

id                           url                   rank     ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号