ÇóÒ»sqlÓï¾ä - MS-SQL Server / »ù´¡Àà
±í
id bh
1 10
2 11
3 12
4 15
5 16
6 22
7 25
8 26
9 27
10 28
½«bh°´Á¬Ðø·Ö¶Î³öÀ´·µ»Ø×Ö·û´®£º
10~12£¬15~16£¬22£¬25~28
SQL code:
declare @t table(num int)
insert into @t select 1
union all select 2
union all select 3
union all select 4
union all select 5
union all select 12
union all select 17
union all select 18
union all select 19
union all select 20
union all select 25
select
rtrim(a.num)+(case when min(b.num)!=a.num then '-'+rtrim(min(b.num)) else '' end)
from
(select t.num from @t t where not exists(select 1 from @t where num=t.num-1)) a,
(select t.num from @t t where not exists(select 1 from @t where num=t.num+1)) b
where
a.num<=b.num
group by a.num
-------------------------
1-5
12
17-20
25
*/
{{
Ïà¹ØÎÊ´ð£º
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
Êý¾Ý¿âÒªÔõôѧ²Å²»»áÏԵóéÏó°¡£¿
Õâ¾ÍÒª¿´ÄãÊʺÏʲô·½·¨ÁË£¬Õâ¾ßÌå²»ºÃ˵µÄ.....
ÔõôÁË£¬ÄѵÀ´ó¼Ò¶¼²»»á£¬»¹ÊÇÕæµÄÌ«³éÏó´ó¼Ò²»ÖªµÀÔõô˵°¡
½áºÏÄã²Ù×÷Êý¾Ý¿âµÄÌå»áºÍÀí½â£¬Ó¦¸ÃЧ¹û»á¸üºÃ¡£·ñÔò£¬Ò ......
ÎÒÃÇC#×öÒ»¸ö´°Ìå ÍùÊý¾Ý¿âÀï²åÈëÊý¾Ý
SqlConnection cn = new SqlConnection("Data Source=20090713-1752\\SQLEXPRESS;Initial Catalog=goods;Integrated Security=True");
......
ÎÒÊÇÔÚtoadÖÐÊäÈë϶Îsql
declare
TYPE test_rec IS record(
code varchar(10),
name varchar(30)
);
v_book test_rec;
......
ÏëÓÃSQL CLR×öÈçϵĴ洢¹ý³Ì,µ«ÊÇ·¢ÏÖ±¨´í:
{ÓÉÓÚ´úÂëÒѾ¹ýÓÅ»¯»òÕß±¾»ú¿ò¼ÜλÓÚµ÷ÓöÑÕ»Ö®ÉÏ£¬ÎÞ·¨¼ÆËã±í´ïʽµÄÖµ¡£}
¶øÇÒÈç¹ûÊý¾Ý´Ócase 1ͨ¹ýʱ¾ÍÊÇÕýÈ·µÄ,´Ócase 2ͨ¹ýʱ´íÎó
²¢ÇÒÔÚc ......