ÇóSQLÓï¾ä
ÏÖÔÚÓÐÁ½Õűí
a±íºÍb±í
a±í:
¹¤ºÅ ÐÕÃû ËùÊô²¿ÃűàºÅ
001 A
002 B
003 A
004 A
005 C
006 D
007 B
008 D
.................
b±í:ÌáÒé±í
ÌáÒé±àºÅ ÌáÒéÈË ËùÊô²¿ÃűàºÅ
1 006 D
2 005 C
3 005 C
4 007
5 002
6 006
7 001
8 002
...........................
ÏÖÔÚҪͳ¼Æ¸÷²¿ÃŵÄÈ˾ùÌáÒéÊý
Á½¸öGROUP BY
±íÁ¬½Ó +group by
ÄÜ·ñ¾ßÌåµã
¸ãÁË°ëÌì,Ò²ÊÇÓñíÁ¬½Ó +group by,µ«ÊÇûÓгɹ¦
ÊÔÊÔ
SQL code
{{----}
Ïà¹ØÎÊ´ð£º
ÏÖÔÚÓÐÁ½¸öÒì¹¹µÄsql serverÊý¾Ý¿â,ÎÒÏ뽫µÚÒ»¸ö±íÖеÄÊý¾Ýµ¼Èëµ½µÚ¶þ¸ö±íÖÐ,×Ô¼ºÖ¸¶¨µ¼ÈëÊý¾ÝµÄ×Ö¶Î,ÈçºÎµ¼ÈëÊý¾ÝÄØ,´ó¼ÒÌÖÂÛÒ»ÏÂ?
dts¹¤¾ß
µ¼Èëµ¼³ö¹¤¾ß.
DD
¹þ¹þ£¬¹À¼ÆÕâλÊǵØQIOU¶¼Êܲ»Á˵Ä
Ö±½ÓÐ ......
СµÜÊǸöÐÂÊÖ ÏÖÔÚÓиöÎÊÌâÒ»Ö±²»Äܽâ¾ö
ÀýÈç
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
¸÷λ´óÏÀ£¬ÎÒÓÐÒ»¸öxmlÎļþ
XML code:
<?xml version="1.0" encoding="GB2312"?>
<FileId fileid="86">
<ResultSet>
<row id="0">
......
ÓÐÁ½Õűí T1, T2
T1:
id, name, T2id £¬discription
T2:
id, subName
ÆäÖÐ T1µÄ T2id ÓëT2µÄ id ¶ÔÓ¦
ÏëÒÔT1µÄ name ºÍ T2µÄ subName Ϊ Ìõ¼þ ²éÑ°T1µÄ discripton.
Çë¸ßÊÖÖ¸µ ......
Çë°ïæ¿´¿´ÔõôÓÅ»¯Ò»Ï£¬¸Ã±íÊý¾ÝԼΪ66Íò£¬ÔËÐÐʱ¼äÒª19Ãë,SQLÈçÏ£º
select DATEPART (hh ,Date_time ) as Hours ,
sum(Counts)*100.0/(Select sum(Counts) as total
&nbs ......