ÇóÒ»SQLÓï¾ä - MS-SQL Server / Ó¦ÓÃʵÀý
Óжà¸öÓû§,¶øÃ¿¸öÓû§ÓÖ·¢²¼Á˺ܶàÐÅÏ¢,ÎÒÏëÌáȡÿ¸öÓû§Í¨¹ýÉóºËµÄ×îÐÂÈýÌõÐÅÏ¢,Ò²¾ÍÊÇÿ¸öÓû§Ö»ÌáÈ¡Ëû·¢²¼µÄ×îÐÂÈýÌõÐÅÏ¢,°´ÕÕ½ðÅÆ»áÔ±,ÒøÅÆ»áÔ±,ÆÕͨ»áԱ˳ÐòÅÅÐò¡£ ÓÐÁ½¸ö±í,Ò»¸ö»áÔ±±í,Ò»¸ö¼Û¸ñ±í,Á½¸ö±í×îºÃͨ¹ýgs_id¹ØÁª£¬ÒÔ·½±ã»áÔ±ÅÅÐò
Ïàͬgs_id×î¶àÏÔʾ3Ìõ¼Ç¼
±í½á¹¹ÈçÏ£º
id cunname gs_id
1 a 1
2 b 1
3 c 1
4 d 1
5 e 2
6 f 2
7 g 2
8 h 2
9 i 2
10 j 3
You need to provide the table structure clearly. What are the table names, and what are the columns and how are they linked?
SQL code:
----------------------------------------------------------------
-- Author :fredrickhu(СF£¬Ïò¸ßÊÖѧϰ)
-- Date :2010-05-06 20:54:09
-- Version:
-- Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86)
-- Nov 24 2008 13:01:59
-- Copyright (c) 1988-2005 Microsoft Corporation
-- Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3)
--
---------------------------------------------------------
Ïà¹ØÎÊ´ð£º
½ñÌì×öÁËÒ»¸ö´æ´¢¹ý³Ì »·¾³ÊÇSQL2000Êý¾Ý¿â
´óÖÂÈçÏÂ
½¨Á¢ÁÙʱ±í
¶¨ÒåÔ±¹¤Óαê
Ñ»·Ô±¹¤£¨ÊôÓÚ1¸ö¹«Ë¾)
......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......
3̨µçÄÔ£¬ÆäÖÐһ̨×÷ΪMYSQL·þÎñÆ÷£¬ÁíÍâ2̨ΪTOMCAT·þÎñÆ÷¡£
MYSQL·þÎñÆ÷ÀïÓÐÒ»Ìõ¼Ç¼£¬ IDΪ10.
ÏÖÔÚ2̨TOMCATͬʱ£¨100%£©·¢ÆðÐÞ¸ÄMYSQLÀïIDΪ10µÄÄÇÌõ¼Ç¼£¬±ÈÈçÐ޸ĴËID¼Ç¼ÀïijһÏîµÄÄÚÈÝ¡£ ±ÈÈçTOMCAT 1Ò ......
²éѯѧÉúƽ¾ù³É¼¨¼°ÆäÃû´Î
SELECT 1+(SELECT COUNT( distinct ƽ¾ù³É¼¨)
from (SELECT S#,AVG(score) AS ƽ¾ù³É¼¨
from SC&n ......