SQLÓï¾ä£º°Ñͳ¼Æ½á¹û°´ÕÕÌض¨µÄÁÐֵת»»³É¶àÁÐ
ÒªÇ󣺲éѯÿ¸öÀÏʦËù´ø±ÏÒµÉè¼ÆµÄ»ã×ÜÇé¿ö£¬±ÏÒµÉè¼ÆѧÉú·Ö±¾¿Æ¡¢×¨¿Æ£¬ÔºÍâ¡¢ÔºÄÚ£¬ÒªÇóµÃµ½µÄ½á¹ûÐÎʽÈçÏ£º
½ÌʦÃû ÔºÄÚ±¾¿Æ Ô°ÄÚר¿Æ ÔºÍâ±¾¿Æ ÔºÍâר¿Æ ºÏ¼Æ
Ïà¹ØµÄ±íÓУºÑ§Éú±í£¨°üº¬Ñ§Éú²ã´Î£©¡¢½Ìʦ±í£¨½ÌʦÃû£©¡¢Ñ§Éú¿ÎÌâ±í£¨Ñ§Éú½Ìʦ¶ÔÓ¦¹ØϵÒÔ¼°ÔºÄÚÔºÍâÐÅÏ¢£©¡£
SQLÓï¾äÈçÏ£º
select
teacher.teacher_name,ifnull(c1.c,0) v1,ifnull(c2.c,0) v2,ifnull(c3.c,0) v3,ifnull(c4.c,0) v4,
(ifnull(c1.c,0)+ifnull(c2.c,0)+ifnull(c3.c,0)+ifnull(c4.c,0)) sum
from teacher
left outer join
(
select
teacher_id,count(*) c
from
taskbook,student
where
taskbook.taskbook_inner_task='ÔºÄÚ' and degree_id>1 and student.student_id=taskbook.student_id
group by
teacher_id
) c1 using(teacher_id)
left outer join
(
select
teacher_id,count(*) c
from
taskbook,student
where
taskbook.taskbook_inner_task='ÔºÄÚ' and degree_id=1 and student.student_id=taskbook.student_id
group by
teacher_id
) c2 using(teacher_id)
left outer join
(
select
teacher_id,co
Ïà¹ØÎĵµ£º
CREATE PROC [dbo].[UP_EC_JOB_UpdateAddressType]
(
@Count INT
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @TransactionNumber INT
DECLARE @Cursor CURSOR
SET @C ......
¡¡¡¡
¡¡¡¡¡ô¾¡Á¿²»ÒªÔÚwhereÖаüº¬×Ó²éѯ;
¡¡¡¡¹ØÓÚʱ¼äµÄ²éѯ£¬¾¡Á¿²»ÒªÐ´³É£ºwhere to_char(dif_date,'yyyy-mm-dd')=to_char('2007-07-01','yyyy-mm-dd');
¡¡¡¡¡ôÔÚ¹ýÂËÌõ¼þÖУ¬¿ÉÒÔ¹ýÂ˵ô×î´óÊýÁ¿¼Ç¼µÄÌõ¼þ±ØÐë·ÅÔÚwhere×Ó¾äµÄĩβ;
¡¡¡¡from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖа ......
from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£
¡¡¡¡Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé:
¡¡¡¡¡ô¾¡Á¿²»ÒªÔÚwhereÖаüº¬×Ó²éѯ;
¡¡¡¡¹ØÓÚʱ¼äµÄ²éѯ£¬¾¡Á¿²»ÒªÐ´³É£ºwhere to_char(dif_date,'yyyy-mm-dd')=to_char('2007-07-01',' ......
ÓÐÕâÑùÒ»¸ö×Ö·û´®(ÖÐ,¹ú,ÖÐ,ÈËÃñ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú)
´¦Àí¹ýÖ®ºó±ä³É(ÖÐ,¹ú,ÈËÃñ,ÏÖ´ú¹¤Òµ»¯½ø³Ì)
ÒÔÏÂÊÇÎҵķ½·¨,ÓÐʲô²»¶ÔµÄµØ·½»¹Çë¸÷λָµã
------------------ɾ³ýÖظ´µÄ×Ö·û
declare
@v1 nvarchar
......