Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQL GROUP BYÎÊÌâ - MS-SQL Server / »ù´¡Àà

Êý¾Ý¿âSQL²éѯÓï¾äÈçÏ£º
  create view grade_student(ѧºÅ,ÐÕÃû,Ñ¡¿ÎÃÅÊý,ƽ¾ù·Ö,×î¸ß·Ö,×îµÍ·Ö)
as
select sc.sno,sname,count(cno),avg(grade),max(grade),min(grade)
from sc,student 
where student.sno=sc.sno
group by sname,sc.sno
 ÎÊÌ⣺ 
 ÔÚ×îºóµÄGROUP BY Óï¾ä¼ÓÉÏ·âºÅ£¨;£©×÷ΪÓï¾äÍê½á Ϊʲô¾Í²»ÄÜÔËÐÐÁË ²»¼ÓÈ´¿ÉÒÔ
ÉèÖÃÎÊÌ⣿
¼ÓÉÏ;ÊÇ¿ÉÒÔµÄàÞ

SQL code:
'¿ÉÒÔÔËÐа¡...'
if object_id('tb')is not null drop table tb
if object_id('test')is not null drop view test
go

create table tb
(
id int,
date datetime
)
go

alter table tb add default getdate() for date
go

insert into tb(id) select 1
union all select 3
union all select 2
union all select 4
go

create view test
as
select id,date=max(date) from tb
group by id;
go

select * from test
/*
id date
---------------------------------
1 2010-04-26 12:42:53.827
2 2010-04-26 12:42:53.827
3 2010-04-26 12:42:53.827
4 2010-04-26 12:42:53.827
*/


Äã²»»áÿ¾ä¶¼¼Ó°É Ö±½ÓÊÇ¿ÉÒÔµÄ

sql server²»ÓÃ¼Ó £»

ÇëÇл»ÊäÈë·¨

create view grade_student(ѧºÅ,ÐÕÃû,Ñ¡¿ÎÃÅÊý,ƽ¾ù·Ö,×î¸ß·Ö,×îµÍ·Ö)
as
select sc.sno,sname,count(cno),avg(grade),max(grade),min(grade)
from sc,student  
where student.sno=sc.sno
group by sname,sc.sno


--><


Ïà¹ØÎÊ´ð£º

jspÁ´½Ósql2000µÄÒÉÎÊ£¿



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

Çë½ÌsqlÓï¾ä¡£ - Oracle / ¿ª·¢

ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
  ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......

Êý¾ÝÒÔxml¸ñʽ·µ»Ø - MS-SQL Server / Ó¦ÓÃʵÀý

´ÓÊý¾Ý¿âÖвéѯһÕűíµÄÊý¾Ý
select ²¿ÃÅ,ÐÕÃû from tb
ÈçºÎ²ÅÄÜÉú³ÉÏÂÃæµÄxml¸ñʽ
XML code:
<folder state="unchecked" label="È«²¿">
¡¡¡¡ <folder state="unchecked&qu ......

MS SQL×÷ÒµÎÊÌâ - MS-SQL Server / Ó¦ÓÃʵÀý

ÈçºÎÔÚSQL2005ÖÐÉ趨¶¨Ê±×÷Òµ£¬±ÈÈç˵¶¨Ê±ÇåÀíijЩ±íµÄÊý¾Ý£¬
»òÕßÊǶ¨Ê±µÄ½«Ä³Ð©±íµÄÊý¾Ýµ¼³öexcel£¡
ÔÚÏߵȴý£¬¼±¼±¼±£¬×îºÃÊÇÏêϸ²½Ö裡
֮ǰÎÒ×öµÄ×÷ÒµÓеãÎÊÌ⣡
°ïUP

²Î¿¼:http://hi.baidu.com/toiota ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ