ÇóÒ»¸öSQLµÃ²éѯÓï¾ä
ÒÑÖªÒ»¸ö¹©Ó¦Çé¿ö±í SPJ
ÓÐÊôÐÔ ¹©Ó¦É̺ÅÂë SNO
Áã¼þºÅÂë PNO
¹¤³ÌÏîÄ¿ºÅÂë JNO
Áã¼þÊýÁ¿ QTY
ÇóÂú×ãÏÂÃæÒªÇóµÄ¹©Ó¦É̺ÅÂ룬¸Ã¹©Ó¦É̹©Ó¦¸øij¸ö¹¤³ÌÁã¼þP1 µÄÊýÁ¿´óÓÚÕâ¸ö¹¤³Ì±»¹©Ó¦µÄÁã¼þP1 µÄƽ¾ùÊýÁ¿¡£
Õâ¸öÎÊÌâµÄSQL²éѯÓï¾äÔõôд°¡£¿
½á¹ûÄØ
SQL code:
SELECT SNO from SPJ WHERE QTY>(
SELECT AVG(QTY) from SPJ)
[code=SQL][/code]
CREATE TABLE SPJ(SNO NVARCHAR(8),PNO NVARCHAR(8),JNO NVARCHAR(8),QTY NVARCHAR(8)
)
INSERT SPJ
SELECT N'S1',N'P1',N'J1',N'200' UNION ALL
SELECT N'S1',N'P1',N'J3',N'100' UNION ALL
SELECT N'S1',N'P1',N'J4',N'700' UNION ALL
SELECT N'S1',N'P2',N'J2',N'100' UNION ALL
SELECT N'S2',N'P1',N'J1',N'400' UNION ALL
SELECT N'S2',N'P3',N'J2',N'200' UNION ALL
SELECT N'S2',N'P3',N'J4',N'500'
GO
SELECT SNO
from SPJ
WHERE QTY >(
SELECT AVG(CAST(QTY AS INT))
from SPJ
)
/*
SNO
--------
S1
S2
S2
£¨ËùÓ°ÏìµÄÐÐÊýΪ 3 ÐУ©
*/
SQL code:
SQL codeSELECT SNOfrom SPJ WHERE QTY>
(SELECT AVG(QTY)from SPJ WHERE JNO='P1' AND PNO='P1' )
SQL code
Ïà¹ØÎÊ´ð£º
½«Ò»¸ö±í21~30ɾ³ý£¬sqlÓï¾äÔõôд
Õâ¸öÌ«ÁýͳÁË£¬ÊÇÅÅÐòºóµÄµÚ21Ìõµ½30Ìõ¼Ç¼ɾ³ý»¹ÊÇijһÁÐÖµÔÚ21µ½30Ö®¼äµÄɾ³ý°¡£¿
21-30ÊÇʲôÒâ˼£¿×ֶεĻ°¾Ídelete from table1 where col1>=21 and col1<=30
Ö¸µ ......
±íÈçÏÂ
½ÌÊÒID ×ùλÊý ¿ªÊ¼Ê±¼ä ½áÊøʱ¼ä 2009Äê1ÔÂ1ÈÕ 2009Äê1ÔÂ2ÈÕ 2009Äê1ÔÂ3ÈÕ
101 50 08£º00 08£º30 30 40 50
101 50 09£º00 ......
Ö±½ÓÆô¶¯ µãÁ˵ÈÒ»»á¶ù¾Íû·´Ó¦ÁË È¥·þÎñÄÇÀïÆô¶¯»á³öÏÖÈçÏÂÌáʾ
³öÏÖ¡°±¾µØ¼ÆËã»úÉϵÄMSSQLSERVER·þÎñÆô¶¯ºóÓÖÍ£Ö¹ÁË¡£Ò»Ð©·þÎñ×Ô¶¯Í£Ö¹£¬Èç¹ûËüÃÇûÓÐʲô¿É×öµÄ
È»ºó»¹ÓÐʲôʲô²»´æÔÚ
......
ÓÐÁ½¸öͬÑùµÄ±í½á¹¹
±í½á¹¹ÈçÏ£º
id£¨ÐòºÅ£© parentid £¨¸¸½áµãÐòºÅ£© name(½áµãÃû³Æ)
±í1 ¼Ç¼ 1 0 aaa
2 ......
³¡¾°ÈçÏ£º
¿Í»§°Ñ±¸·ÝºÃµÄÊý¾Ý¿â£¬·¢¸øÎÒ£¬ÎÒÔÚ±¾»ú»¹Ôºó£¬ÔËÐÐдºÃµÄ´æ´¢¹ý³Ì£¬±È½Ï¿ì£¬²¢ÇÒÔÚʵʩÄDZßÔËÐÐͬÑù±È½Ï¿ì¡£µ«Êǵ±ÊµÊ©ÔÚ¿Í»§ÄDZßÔËÐеÄʱºòËٶȾͷdz£µÄÂý£¬Ê±¼ä³¬³öÁ˳ÌÐòµÄʱ¼äÏÞÖÆ¡£Ô¶³ÌÔÚ¿Í»§ÄÇ ......