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

SQL 每个分类各取2条数据

create table tb (ptoid int,proclassid int,proname varchar(10))
insert tb
select 1,1,'衣服1'
union all
select 2,2,'衣服2'
union all
select 3,3,'衣服3'
union all
select 4,3,'衣服4'
union all
select 5,2,'衣服5'
union all
select 6,2,'衣服6'
union all
select 7,2,'衣服7'
union all
select 8,1,'衣服8'
select * from tb
ptoid       proclassid  proname   
----------- ----------- ----------
1           1           衣服1
2           2           衣服2
3           3           衣服3
4           3           衣服4
5           2           衣服5
6           2           衣服6
7           2           衣服7
8           1           衣服8
(所影响的行数为 8 行)
select * from tb a where
(select count(*) from tb b where b.proclassid=a.proclassid and b.ptoid>a.ptoid) <2
order by proclassid
ptoid       proclassid  proname   
----------- ----------- ----------
1           1           衣服1
8           1   


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

MyEclipse5.5下连接Sql Server 2008的方法

下面是指导文档。请跟着一步步的做。就能成功连接上sql server 2008
 
java中连接sql server 2008的注意事项:
2000,2005的数据库驱动类的写法是:
com.microsoft.jdbc.sqlserver.SQLServerDriver
URL的写法是:假设数据库是news
jdbc:microsoft:sqlserver://localhost:1433;databaseName=news
 
但是20 ......

SQL XML DELETE

--A. 从存储在非类型化的 xml 变量中的文档中删除节点
DECLARE @myDoc xml
SET @myDoc = '<?Instructions for=TheWC.exe ?>
<Root>
 <!-- instructions for the 1st work center -->
<Location LocationID="10" LaborHours="1.1" MachineHours=".2" >
 Some text 1
 <st ......

在Delphi中拼装SQL语句的注意点

我使用delphi也不是很长时间,由于经常要用到SQL语句,总结了一些Delphi中使用SQL语句要注意的事项,归纳起来主要有一下几条:
一、空格不要漏:
我们经常要拼装SQL语句,特别是where条件句,在各个语句中别忘了头尾加上空格。因为在一个语句中我们会注意用空格分开关键字但是往往忘了头尾的空格。例如:
sSQL=' select ......

sql 加密

use Tempdb
go
if object_ID ( 'fn_ACITEncryption' ) is not null
drop function fn_ACITEncryption
go
create function fn_ACITEncryption
(
@Str nvarchar ( 4000), -- 加密的字符串
@Flag bit = 1, --1 、加密 0 、解密
@Key nvarchar ( 50) -- 密文
)
returns nvarchar ( 4000) ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号