sql ÐÐתÁÐµÄ ÎÊÌâ
Ôʼ±í
ÐÕÃû 01Äê³É¼¨ 02Äê³É¼¨ 03Äê³É¼¨ 04Äê³É¼¨
ÕÅÈý 98 78 68 88
ÀîËÄ 86 56 99 78
½á¹û±í
ÐÕÃû ÕÅÈý ÀîËÄ
01Äê³É¼¨ 98 86
02Äê³É¼¨ 78 56
03Äê³É¼¨ 68 99
04Äê³É¼¨ 88 78
ÉÏÃæµÄÐÕÃû±ØÐëÊǶ¯Ì¬µÄ ÔÚÏßµÈ
×¢Òâ ¿ÉÒÔ¸ù¾Ý Ìõ¼þ²éѯ ¿ÉÒÔ²éѯ³ö¶àÌõÊý¾ÝµÄ
³É¼¨Êǹ̶¨µÄô£¿
¡£¡£¡£¡£¡£¡£¡£
ÐÕÃû 01Äê³É¼¨ 02Äê³É¼¨ 03Äê³É¼¨ 04Äê³É¼¨ Õ⼸¸öÁÐÊǹ̶¨µÄ ¸ã¶¨ ¾Í½áÌù ×îºÃ ²»ÒªÓà ¾ÛºÏº¯ÊýÀàµÄ ÒòΪÐÕÃû »áÖØ¸´ ÓÐÖ÷¼ü Çø·ÖµÄ
SQL code:
ÁÐתÐÐ
--> --> (Roy)Éú³É測試數據
if not object_id('Class') is null
drop table Class
Go
Create table Class([Student] nvarchar(2),[Êýѧ] int,[ÎïÀí] int,[Ó¢Óï] int,[ÓïÎÄ] int)
Insert Class
select N'ÀîËÄ',77,85,65,65 union all
select N'ÕÅÈý',87,90,82,78
Go
--2000:
¶¯Ì¬:
declare @s nvarchar(4000)
select @s=isnull(@s+' union all ','')+'select [Student],[Course]='+quotename(Name,'''')--isnull(@s+' union all ','') È¥µô×Ö·û´®@sÖеÚÒ»¸öunion all
+',[Score]='+quotename(Name)+' from Class'
from syscolumns where ID=object_id('Class') and Name not in('Student')--Åųý²»×ª»»µÄÁÐ
order by Colid
exec('select * from ('+@s+')t order by [Student],[Course]')--Ôö¼ÓÒ»¸öÅÅÐò
Éú³É¾²Ì¬:
select *
from (select [Student],[Course]='Êýѧ',[Score]=[Êýѧ] from
Ïà¹ØÎÊ´ð£º
ÎÒÒ»¸öÏîÄ¿£¬Óиö²åÈë²Ù×÷£¬¾ßÌåÊÇÕâÑùµÄ£º
ÎÒÓнø»õÐÅÏ¢±í¡£ÔÚ³ö»õʱѡÔñÏàÓ¦µÄ½ø»õÐÅÏ¢£¬ÊäÈëÊýÁ¿£¬Ñ¡Ôñ²¿Ãź󣬵㱣´æ°´Å¥£¬ÓÉÓÚÍøÂçÑÓʱ£¬µãÒ»ÏÂûÓз´Ó³£¬ÓÚÊÇÓû§¾ÍÓÖµãһϣ¬µ¼ÖÂÒ»´Î²åÈëÁËÁ½Ìõ¼Ç¼:
Àý£º
......
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......
±í
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 tabl ......
µÚÒ»¾ä:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm
join jh on ht.htbh=jh.hth
and ht.htbh not like'del%' and ht. ......