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

SQL °´Ô²éѯ

ÏîÄ¿ÖÐÐèÒª¸ù¾Ý¿Î¼þÃû³Æ°´ÔÂͳ¼Æ³ö·ÃÎʵÄÇé¿ö£¬µÚÒ»´ÎÎÒ²ÉÓÃÁË×îÍÁµÄÒ»ÖÖ°ì·¨£¬Ê¹ÓÃÑ­»·£¬¸øsql´«µÝÄêÔÂÁ½¸ö²ÎÊý£¬
for(var y=2009;y<=2010;y++){
    for(var m=1;m<=12;m++){
          // todo : SQL ²éѯ
    }
}
ÕâÑù£¬Í³¼Æ2009Äêµ½2010ÄêµÄÔ±¨±í£¬¾ÍÐèҪѭ»·2*12 ´Î£¬Èç¹ûÊý¾Ý¿âÖÐijÔ²¢Î´ÓÐÊý¾Ý£¬ÄÇô¾ÍµÈÓÚÊÇ°×°×Õ¼Óôø¿íÇëÇó·þÎñÆ÷ÁË¡£
¾­¹ýlinchunµÄµã²¦£¬½áºÏ±ù¸ç֮ǰµÄ²éѯ£¬Ê¹ÓÃConvert ºÍDatepart ¼´¿ÉʵÏÖÕâÖÖ²éѯ£¬È»ºóÔÙÔÚǰ̨ͨ¹ýJavaScript´¦ÀíÊý¾Ý¡£
SELECT a.[ID]
,a.[Name]
,fna(a.[ID], CONVERT([datetime],CONVERT([varchar](8),b.[Timestamp],(102))+'01',0) ) as UserCount ,(CONVERT([datetime],CONVERT([varchar](8),b.[Timestamp],(102))+'01',0)) as ReportDate
from [dbo].[lcms_CourseWare] a
inner join [dbo].[lcms_SessionTime] b
on a.[ID] = b.[CourseWareID]
where [State]=1
and [DelFlag]=0
group by (CONVERT([datetime],CONVERT([varchar](8),b.[Timestamp],(102))+'01',0))
,a.[ID],a.[Name]
ÔÚfunction ÖУ¬½ÓÊÕʱ¼ä²ÎÊý£º
CREATE FUNCTION fna(
@CourseWareID varchar(32)
, @ReportDate datetime
)
RETURNS bigint
AS
BEGIN
RETURN (
SELECT COUNT(distinct [UserID])
from [dbo].[lcms_SessionTime]
WHERE CourseWareID = @CourseWareID
and year([Timestamp])=DATEPART(YEAR,@ReportDate)
and month([Timestamp])=DATEPART(MONTH,@ReportDate)
)
END
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO


Ïà¹ØÎĵµ£º

VB+SQL±àдÊý¾Ý¿â¹ÜÀíϵͳ

     ²ÎÕÕ°¸Àý½Ì³Ì½¨Á¢µÄÊý¾Ý¿â¹ÜÀíϵͳÔÚÉõ¶à·½Ã涼´æÔÚÎÊÌâ¡£¿ÉÄÜÊÇÐÂÊÖ£¬²»¹ÜÊǶÔÓÚ´óÒ»¾Íѧ¹ýµÄVB±à³Ì»¹ÊÇÕâ¸öѧÆÚ¸Õ½Ó´¥µÄSQL£¬ºÜ¶àСÎÊÌâ³£³£³öÏÖÔÚµ÷ÊÔ¹ý³ÌÖС£ÏëÇëÊìϤʹÓÃÕâÁ½¸öƽ̨µÄ¸ßÊÖ°ïæָµãһϡ£
     1.ÈçºÎ½â¾öDataGridÖжà¸öcolumnºÍSQLÖжà¸ö±íµÄ°ó¶¨£¿Ä¿µÄ ......

ÓйØSQLÓÅ»¯

Oracle SQLÐÔÄÜÓÅ»¯¼¼ÇÉ´ó×ܽá ÊÕ²Ø
 £¨1£©Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
  OracleµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔ ......

SQL Server ÄêÔÂÈÕ¼ÆËã

SQL Server 2000/2005 ÄêÔÂÈÕ¼ÆËã·½·¨
ͨ³££¬ÄãÐèÒª»ñµÃµ±Ç°ÈÕÆںͼÆËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬ÄãµÄ³ÌÐò¿ÉÄÜÐèÒªÅжÏÒ»¸öÔµĵÚÒ»Ìì»òÕß×îºóÒ»Ìì¡£ÄãÃÇ´ó²¿
·ÖÈË´ó¸Å¶¼ÖªµÀÔõÑù°ÑÈÕÆÚ½øÐзָÄê¡¢Ô¡¢Èյȣ©£¬È»ºó½ö½öÓ÷ָî³öÀ´µÄÄê¡¢Ô¡¢ÈյȷÅÔÚ¼¸¸öº¯ÊýÖмÆËã³ö×Ô¼ºËùÐèÒªµÄÈÕÆÚ£¡ÔÚÕâƪÎÄÕÂÀÎÒ½«¸æËßÄã
ÈçºÎÊ¹Ó ......

ÐÐÁÐתÖõÄSQLÓï¾ä

ÐÐÁÐתÖõÄSQLÓï¾ä
ÁíÒ»ÖÖÐÐÁÐתÖà -- ¶¯Ì¬ sql ½»²æ±í =========================================================== ×÷Õß: wxy0327(http://wxy0327.itpub.net)
·¢±íÓÚ: 2006.05.10 09:11
·ÖÀà: Oracle
³ö´¦: http://wxy0327.itpub.net/post/16888/88075
-------------------------- ......

SQL Server º¯Êý´óÈ«

SQL Server×Ö·û´®´¦Àíº¯Êý´óÈ«
 selectÓï¾äÖÐÖ»ÄÜʹÓÃsqlº¯Êý¶Ô×ֶνøÐвÙ×÷£¨Á´½Ósql server£©£¬
select ×Ö¶Î1 from ±í1 where ×Ö¶Î1.IndexOf("ÔÆ")=1;
ÕâÌõÓï¾ä²»¶ÔµÄÔ­ÒòÊÇindexof£¨£©º¯Êý²»ÊÇsqlº¯Êý£¬¸Ä³Ésql¶ÔÓ¦µÄº¯Êý¾Í¿ÉÒÔÁË¡£
left£¨£©ÊÇsqlº¯Êý¡£
select ×Ö¶Î1 from ±í1 where charindex£¨'Ô ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ