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

SQLº¯Êý´óÈ«2

--
¾ÛºÏº¯Êý
use
pubs
go
select

avg
(
distinct
price)  
--
ËãÆ½¾ùÊý
from
titles
where
type
=
'
business
'
go

use
pubs
go
select

max
(ytd_sales)  
--
×î´óÊý
from
titles
go

use
pubs
go
select

min
(ytd_sales)
--
×îСÊý
from
titles
go

use
pubs
go
select
type,
sum
(price),
sum
(advance)  
--
ÇóºÍ
from
titles
group

by
type
order

by
type
go

use
pubs
go

select

count
(
distinct
city)  
--
Çó¸öÊý
from
authors
go

use
pubs
go
select

stdev
(royalty)
--
·µ»Ø¸ø¶¨±í´ïʽÖÐËùÓÐÖµµÄͳ¼Æ±ê׼ƫ²î
from
titles
go

use
pubs
go
select

stdevp
(royalty)
--
·µ»Ø±í´ïʽÖÐËùÓÐÖÆµÄÌî³äͳ¼Æ±ê׼ƫ²î
from
titles
go

use
pubs
go
select

var
(royalty)
--
·µ»ØËùÓÐÖµµÄͳ¼Æ·½²î
from
titles
go

use
pubs
go
select

varp
(royalty)
--
·µ»ØËùÓÐÖµµÄÌî³äµÄͳ¼Æ·½²î
from
titles
go

--
Êýѧº¯Êý
select

sin
(
23.45
),
atan
(
1.234
),
rand
(),
PI
(),
sign
(
-
2.34
)
--
ÆäÖÐrandÊÇ»ñµÃÒ»¸öËæ»úÊý
--
ÅäÖú¯Êý
SELECT

@@VERSION

--
»ñÈ¡µ±Ç°Êý¾Ý¿â°æ±¾
SELECT

@@LANGUAGE

--
µ±Ç°ÓïÑÔ
--
ʱ¼äº¯Êý
select

getdate
()
as

'
wawa_getdate
'

--
µ±Ç°Ê±¼ä
select
getutcdate()
as

'
wawa_getutcdate
'

--
»ñÈ¡utcʱ¼ä
select

day
(
getdate
())
as

'
wawa_day
'

--
È¡³öÌì
select

month
(
getdate
())
as

'
wawa_month
'

--
È¡³öÔÂ
select

year
(
getdate
())
as

'
wawa_year
'

--
È¡³öÄê
select

dateadd
(d,
3
,
getdate
())
as
wawa_dateadd
--
¼ÓÈýÌì,×¢Òâ'd'±íʾÌì,'m'±íʾÔÂ,'yy'±íʾÄê,ÏÂÃæÒ»Ñù
select

datediff
(d,
'
2004-07-01
'
,
'
2004-07-15
'
)
as
wawa_datediff
--
¼ÆËãÁ½¸öʱ
¼äµÄ²î
select

datename
(d,
'
2004-07-15
'
)
as
wawa_datename
--
È¡³öʱ¼äµÄijһ²¿·Ö
select

datepart
(d,
getdate
())
as
wawa_datepart &


Ïà¹ØÎĵµ£º

SQL_²éѯµ±Ìì¡¢½ü¼¸Ìì¡¢±¾ÖÜ¡¢±¾ÔµÄSQLÓï¾ä

¾­³£»áÓÐʱºòÒªÓõ½²éѯµ±Ì죬½ü¼¸Ì죬±¾ÖÜ£¬±¾ÔµÄÏà¹ØÊý¾Ý£¬ËùÒԼǼһÏÂÕâЩ±È½ÏÌØÊâµÄSQLÓï¾ä~~
--µ±Ìì
(usrRegTime >=CONVERT(varchar(10),getDate(),120)+' 00:00:00' and usrRegTime <=CONVERT(varchar (10),getDate(),120)+' 23:59:59')
--½üÈýÌì
DateDiff(day,usrRegTime,getdate()) <=3
--±¾ÖÜ ......

SQLÊý¾ÝÀàÐÍÏê½â

(1)¶þ½øÖÆÊý¾ÝÀàÐÍ

¡¡¡¡¶þ½øÖÆÊý¾Ý°üÀ¨ Binary¡¢Varbinary ºÍ Image
¡¡¡¡Binary
Êý¾ÝÀàÐͼȿÉÒÔÊǹ̶¨³¤¶ÈµÄ(Binary),Ò²¿ÉÒÔÊDZ䳤¶ÈµÄ¡£
¡¡¡¡Binary[(n)] ÊÇ n λ¹Ì¶¨µÄ¶þ½øÖÆÊý¾Ý¡£ÆäÖУ¬n
µÄȡֵ·¶Î§ÊÇ´Ó 1 µ½ 8000¡£Æä´æ´¢ñ¿µÄ´óСÊÇ n + 4 ¸ö×Ö½Ú¡£
¡¡¡¡Varbinary[(n)] ÊÇ n
λ±ä³¤¶ÈµÄ¶þ½øÖÆÊý¾Ý¡£ÆäÖУ ......

sql2005ÖÐÒ»¸öxml¾ÛºÏµÄÀý×Ó

sql2005ÖÐÒ»¸öxml¾ÛºÏµÄÀý×Ó ÊÕ²Ø
¸ÃÎÊÌâÀ´×ÔÂÛ̳ÌáÎÊ£¬ÑÝʾSQL´úÂëÈçÏÂ
--½¨Á¢²âÊÔ»·¾³
set nocount on
create table test(ID varchar(20),NAME varchar(20))
insert into test select '1','aaa'
insert into test select '1','bbb'
insert into test select '1','ccc'
insert into test select '2','ddd'
inser ......

¾­µäSQLÓï¾ä´óÈ«

ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ