³£ÓÃsqlÓï¾ä
1.ÏÞÖÆ·µ»Ø¼Ç¼µÄÐÐÊý£¨4-10ÐУ©
select rownum,c1 from t144 where rownum<10
minus
select rownum,c1 from t144 where rownum<5
2.ÅúÁ¿²åÈë
insert into tablename(select * from othertable)
»ò
insert into (column1,column2,,,,,,,)tablename(select column1,column2,,,,,,,from othertable)
3,·Ö×麯Êý(½á¹ûÖгöÏÖµÄÁÐÒªÔÚgroup by ÖгöÏÖ)
select count(age), username, , ,... from table group by age,usename,,,,...
4.²é¿´Êý¾Ý¿âÖеĴæÔڵıí
select table_name from dba_tables (include all users)
select * from tab(include view)
5.¸ßЧupdate£¬Ò»´ÎÐ޸Ķà¸öÁÐ
update smsmonitor sms
set (sms.smsmonitor_sendflag, sms.smsmonitor_maxnum) = (select s.smsmonitor_sendflag,
s.smsmonitor_maxnum
from smsmonitor s
where s.smsmonitor_id =
&nbs
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
×î½üÓÐÅóÓÑÓöµ½Ê¡ÊеÄÎÊÌ⣬ÏëÏë×Ô¼º½ñºóÒ²ÓпÉÄÜ»áÓöµ½£¬ËùÒÔ¾Í×Ô¼ºÔÚÍøÉÏдд£¬ËÑËÑ£¬Ö÷ÒªÊǶÔ×Ô¼º½ñºóÓвο¼
--´´½¨Êý¾Ý¿â
create database NationalAll
Go
--ʹÓÃNationalAllÊý¾Ý¿â
use NationalAll
Go
--´´½¨Ê¡¼¶±í
Create Table Province
(
ProID int primary key not null,
ProName nvarchar(50) n ......
ÏîÄ¿ÖÕÓÚ½áÊøÁË£¬×ܽáµÄʱºòµ½ÁË... hehe :)
ÔÚÏîÄ¿ÖÐÎÒÃÇÓöµ½Á˺ܶàµÄÎÊÌ⣬±ê×¼SQLʹÓþÍÊÇÆäÖÐÒ»¸ö¡£ ÒòΪÎÒÃÇÔÚ×öBI packageµÄʱºò£¬Ò»¿ªÊ¼¶¼ÊÇ»ùÓÚMS SQL À´×öµÄ£¬ËùÒÔUniverseµÄÉè¼ÆÉÏҲûÓÐÌ«¶àµÄ¿¼ÂÇ¡£ µ±ºóÀ´ÀÏ´ó¸æËßÎÒÅ ......
ÓÃExcel+VBA+SQL Server½øÐÐÊý¾Ý´¦Àí
ʹÓÃExcel+VBA+SQL Server½øÐÐÊý¾Ý´¦ÀíÊÇÒ»ÖÖ¼òµ¥ÓÐЧ·½·¨£¬ÕÆÎÕÒÔÏ»ù´¡ÖªÊ¶ÊµÏÖ¿ìËÙÈëÃÅ(ÕÆÎÕexcel/vba/sqlserver¸÷1%ÄÚÈÝ£¬Äã¾ÍÄܳÉΪÊý¾Ý´¦Àí¸ßÊÖµÄ:))£º
Ò»¡¢Excel»ù´¡ÖªÊ¶
Á˽⹤×÷²¾(Workbook)¡¢¹¤×÷ ......
ÒÔǰ¶ÔÓÚSql ServerÖÐCaseÃüÁîµÄÓ÷¨Ò»Ö±²»ÊǺÜÁ˽⣬½ñÌìͨ¹ýÉÏÍø²éÁËһЩ×ÊÁÏ£¬½«Case»ù±¾µÄÓ÷¨×ܽáһϡ£
CaseÃüÁîÓÐÁ½ÖÖÓï·¨£º
A£©CASE<ÔËËãʽ>
WHEN <ÔËËãʽ> THEN <ÔËËãʽ>
……
WHEN <ÔËËãʽ> THEN <ÔËËãʽ>
[ELSE<ÔËËãʽ> ......