SQL£ºÈçºÎ°Ñ¶àÐвéѯ½á¹û£¬×÷ΪһÐзµ»Ø
CREATE FUNCTION dbo.UF_GetInvoiceSerials( @bizCode VARCHAR(10))
RETURNS VARCHAR(100)
AS
BEGIN
DECLARE @ret AS VARCHAR(1000)
SELECT @ret=Coalesce(@ret + ', ','') +
CASE e.ID
WHEN '1' THEN c.InvoiceNo
WHEN '2' THEN d.ExpenseNO
ELSE 'N/A'
END
from dbo.Business a WITH(NOLOCK)
LEFT JOIN dbo.Asset_Card b WITH(NOLOCK)
ON b.BusinessID = a.ID
LEFT JOIN dbo.Equipment_Card c WITH(NOLOCK)
ON c.Asset_CardID = b.ID
LEFT JOIN dbo.FurnitureCard d WITH(NOLOCK)
ON d.Asset_CardID = b.ID
LEFT JOIN dbo.Assert_Type e WITH(NOLOCK)
ON e.ID = b.Assert_TypeID
WHERE a.BusinessCode=@bizCode
RETURN Isnull(@ret,'N/A')
END
+++++++++++++++++++++++++++++++++++++++++
Ïà¹ØÎĵµ£º
ͨ¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØϵÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌص㣬ҲÊÇËüÇø±ðÓÚÆäËüÀàÐÍ
Êý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØϵÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹Øϵ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚ
Ò»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷²éѯ³ö´æ·ÅÔÚ¶à¸ö±íÖеIJ»Í¬ÊµÌåµÄÐÅÏ¢¡£Á¬½Ó²Ù×÷¸øÓû ......
--¼à¿ØË÷ÒýÊÇ·ñʹÓà alter index &index_name monitoring usage; alter index &index_name nomonitoring usage; select * from v$object_usage where index_name = &index_name;
--ÇóÊý¾ÝÎļþµÄI/O·Ö²¼ select df.name,phyrds,phywrts,phyblkrd,phyblkwrt,singleblkrds,readtim,writetim from v$filestat fs,v ......
ת×Ôhttp://lavasoft.blog.51cto.com/62575/23373
SQLÓïÑÔµÄCASEÓï¾ä±¸Íü
¸ÅÊö£º
SQLÓï¾äÖеÄCASEÓï¾äÓë¸ß¼¶ÓïÑÔÖеÄswitchÓï¾ä£¬ÊDZê×¼SQLµÄÓï·¨£¬ÊÊÓÃÓëÒ»¸öÌõ¼þÅжÏÓжàÖÖÖµµÄÇé¿öÏ·ֱðÖ´Ðв»Í¬µÄ²Ù×÷¡£Áé»îÓ¦ÓÃCASEÓï¾ä¿ÉÒÔʹSQLÓï¾ä±äµÃ¼ò½àÒ׶Á£¬ÏÂÃæÔÚDB2»·¾³ÏÂͨ¹ýÒ»¸ö¼òµ¥µÄ²éѯÀ´Õ¹Ê¾SQL CASEÓ ......
Ò». ²éÕÒÖظ´¼Ç¼
1. ²éÕÒÈ«²¿Öظ´¼Ç¼
Select * from ±í Where Öظ´×ֶΠIn (Select Öظ´×Ö¶Î
from ±í Group By Öظ´×ֶΠHaving Count(*)>1)
2. ¹ýÂËÖظ´¼Ç¼(Ö»ÏÔʾһÌõ)
Select * from HZT Where ID In (Select Max(ID) from HZT Group By Title)
×¢£º´Ë´¦ÏÔʾID×î´óÒ»Ìõ¼Ç¼
¶þ. ɾ³ýÖظ´¼Ç ......