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

sql·Ö×é²éѯÎÊÌâ

Çé¾°Ò»£º
±íÖÐÊý¾Ý
name  score
 aaa   11
 aaa   19
 bbb   12
 bbb   18
 ccc   19
 ddd   21
ÆÚÍû²éѯ½á¹ûÈçÏÂ
name   score
 aaa     30
 bbb     30
 ccc      19
 ddd     21
Sql´úÂë
---¼ì²é±íÊÇ·ñ´æÔÚ   
if exists(select * from sysobjects where name='testSum')   
drop table testSum   
go   
---´´½¨±í   
create table testSum   
(   
   tid int primary key identity(1,1),   
   tname varchar(30) null,   
   tscor int null  
)   
go   
insert into testSum (tname,tscor)    
select 'aaa',11   
union all    
select 'aaa',19   
union all    
select 'bbb',12   
union all  
select 'bbb',18   
union all  
select 'ccc',19   
union all    
select 'ddd',21   
---²éѯÓï¾ä   
select tname ,sum(tscor) from testSum group by tname   
  
---Ö»²éѯtscor×ܺÍΪ30µÄ   
 select tname ,sum(tscor) from testSum group by tname having sum(tscor)=30  
---¼ì²é±íÊÇ·ñ´æÔÚ
if exists(select * from sysobjects where name='testSum')
drop table testSum
go
---´´½¨±í
create table testSum
(
tid int primary key identity(1,1),
tname varchar(30) null,
tscor int null
)
go
insert into testSum (tname,tscor)
select 'aaa',11
union all
select 'aaa',19
union


Ïà¹ØÎĵµ£º

SQL ËÙ²éÊÖ²á

--SQL ËÙ²éÊÖ²á
/*******************************************/
SELECT
--ÓÃ;£º´ÓÖ¸¶¨±íÖÐÈ¡³öÖ¸¶¨ÁеÄÊý¾Ý
--Óï·¨£º
SELECT column_name(s) from table_name
--Ö÷Òª×Ö¾ä¿ÉժҪΪ:
SELECT select_list [INTO new_table]
from table_source
[WHERE search_condition]
[GROUP BY group_by_expression]
[HAVING s ......

SQLÓï·¨ÊÖ²á


 
 
SQLÓï·¨ÊÖ²á
Select
ÓÃ;£º
 ´ÓÖ¸¶¨±íÖÐÈ¡³öÖ¸¶¨µÄÁеÄÊý¾Ý
Óï·¨£º
 
SELECT column_name(s) from table_name
 
½âÊÍ£º
´ÓÊý¾Ý¿âÖÐѡȡ×ÊÁÏÁУ¬²¢ÔÊÐí´ÓÒ»»ò¶à¸ö×ÊÁϱíÖУ¬Ñ¡È¡Ò»»ò¶à¸ö×ÊÁÏÁлò×ÊÁÏÐС£SELECT ³ÂÊöʽµÄÍêÕûÓï·¨Ï൱¸´ÔÓ£¬µ«Ö÷Òª×Ó¾ä¿ÉժҪΪ£º
SELECT select_ ......

sql ÖÐ case when Óï·¨

sqlÓïÑÔÖÐÓÐûÓÐÀàËÆCÓïÑÔÖеÄswitch caseµÄÓï¾ä£¿£¿
  ûÓÐ,ÓÃcase   when   À´´úÌæ¾ÍÐÐÁË.   
       
  ÀýÈç,ÏÂÃæµÄÓï¾äÏÔʾÖÐÎÄÄêÔ  
   
  select   getdate()   as   ÈÕÆÚ,case   month(get ......

JAVAͨ¹ýODBCÁ´½ÓSQL SERVER

/**
 * @author ºýÍ¿¹í
 * ÔÚ½¨Á¢Á¬½Ó֮ǰÐèҪһЩ׼±¸¹¤×÷£º
 * ÔÚ¿ØÖÆÃæ°åÉÏͨ¹ý“¹ÜÀí¹¤¾ß”µÄ“Êý¾ÝÔ´(ODBC)”´ò¿ª“ODBCÊý¾ÝÔ´¹ÜÀíÆ÷”¶Ô»°¿ò£¬
 * µ¥»÷“ϵͳDSN”Ñ¡Ï£¬È»ºóµ¥»÷“Ìí¼Ó”°´Å¥£¬µÃµ½“´´½¨Êý¾ÝÔ´”¶Ô»°¿ò£¬
......

ÓÃÌæ´ú±äÁ¿µÄ·½Ê½±àдsqlÓï¾ä

SQL> select * from dept where deptno=&tt;
Enter value for tt:20
DEPTNO DNAME          LOC
------ -------------- -------------
    10 ACCOUNTING     NEW YORK
ÕâÑùÎÞÂÛÊäÈë¶àÉÙ´ÎttµÄÖµ£¬ÏµÍ³Ö»½¨Á¢Ò»¸öÖ´Ðмƻ®£¬Ì ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ