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

写了一个稍微复杂点的sql心得

select pcode from (
        select h.k,h.d,h.m,h.u,l.areacode,
               l.areacode||substr(h.u,4,length(h.u))||h.k pcode
         from(
        select j.k,j.d,j.m,j.u from(
        select lpad(f,3,0) as k,d, m,u from(
        select xx.areacode d,nvl(count(cy.pcode),'001')f,mx.m,mx.shopcode u
        from cz_s_jtxx xx, cz_s_jtcy cy , 
          ( select a.m,d.shopid,d.shopcode from
        (select shopid m,parentid from s_shop where shoptype=1) a,
        (select shopid,parentid from s_shop where shoptype=2) b,
        (select shopid,parentid from s_shop where shoptype=3)c,
        (select shopid,parentid,shopcode from s_shop where shoptype=4)d
        where d.parentid=c.shopid
        and c.parentid=b.shopid
        and b.parentid=a.m
        and d.shopid=14725) mx
        where xx.pcode = cy.pcode
        and xx.areacode=mx.shopid
        group by xx.areacode,mx.m,mx.shopcode))j)h, 
        (select areacode,shopid  from cz_s_area) l 
       where h.m=l.shopid)
首先 从最里层的 sql说起:
select a.m,d.shopid,d.shopcode from
        (select shopid m,parentid from s_shop where shoptype=1) a,
    


相关文档:

SQL SERVER 2005 远程访问

(适用 SQL Server 2005 其他版本)
收藏



SQL Server 2005 Express 是微软提供的数据库的低端解决方案,
可免费任意随产品分发, 可以在XP等非专业服务器系统下安装, 还可以远程访问, 对于小型数据应用程序已足够满足数据使用要求.
默认安装下,SQL Server ......

SQL Server连接远程数据源

SQL Server连接远程数据源的基本方法有下面三种:
OPENDATASOURCE
: The OPENDATASOURCE function is used to
specify connection information for a remote data source by specifying
the OLE DB provider and an initialization string. OPENDATASOURCE can be
used directly within a SELECT, INSERT, UPDATE, or ......

在 MS SQL Server 中删除表

-- 说明:
-- 1. 要删除表 table_name, 须先判断该表是否正被数据库中其它表所引用.
-- 2. 如果未被引用, 可直接 DROP TABLE table_name; 否则必须先删除引用表的约束, 再 DROP TABLE table_name.
-- 3. 另外, table_name 是否正引用其它表的情况无须考虑.


-- 创建主表
CREATE TABLE tParent
......

使用自定义表类型(SQL Server 2008)

使用自定义表类型(SQL Server 2008)
http://tech.ddvip.com    2009年09月19日    来源:博客园    作者:陈希章   
  在 SQL Server 2008 中,用户定义表类型是指用户所定义的表示表结构定义的类型。您可以使用用户定义表类型为存储过程或函数声明表值参数,或者声明您要在 ......

SQL Server 2005 中的Row_Number()函数

本文来自:http://www.cnblogs.com/digjim/archive/2006/09/20/509344.html
 我们知道,SQL Server 2005和SQL Server 2000 相比较,SQL Server 2005有很多新特性。这篇文章我们要讨论其中的一个新函数Row_Number()。数据库管理员和开发者已经期待这个函数很久了,现在终于等到了!
 通常,开发者和管理员在一个 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号