日期:2014-05-17 浏览次数:20490 次
1:
select
a.Day As 日期
,a.Amount As 日产
,Sum(b.Amount) As 累计日产
from A As a,A As b
Where a.Day>=b.Day
Group by a.Day,a.Amount
2:
Select
TeacherName
,Max(Case when WeekDays=1 And IsLesson=1 Then N'有课' Else '' End) As 星期一
,Max(Case when WeekDays=2 And IsLesson=1 Then N'有课' Else '' End) As 星期二
,Max(Case when WeekDays=3 And IsLesson=1 Then N'有课' Else '' End) As 星期三
,Max(Case when WeekDays=4 And IsLesson=1 Then N'有课' Else '' End) As 星期四
From TeacherLesson
Group by TeacherName
3:
Select
A
,Min(B) As B
from CC
Group by A
declare @tb table([day] int,amount decimal(10,5))
insert into @tb select 1,3.33333
union all select 2,4.22222
union all select 3,1.5555
union all select 4,9.888
select [day],(select sum(amount) from @tb where [day]<=a.[day]) amount from @tb a
declare @t table(id int,n varchar(10),weekdays int)
insert into @t select 1,'a',2
union all select 2,'a',3
union all select 3,'b',3
union all select 4,'b',4
union all select 5,'c',1
union all select 6,'c',4
union all select 7,'c',2
select n,max(case when weekdays=1 then '有课' else '' end) as 星期一,
max(case when weekdays=2 then '有课' else '' end) as 星期二,
max(case when weekdays=3 then '有课' else '' end) as 星期三,
max(case when weekdays=4 then '有课' else '' end) as 星期四,
max(case when weekdays=5 then '有课' else '' end) as 星期五
from @t group by n
declare @b table(a int,b int)
insert into @b select 1,2
union all select 1,3
union all select 1,4
union all select 2,1
union all select 2,2
union all select 3,1
union all select 4,1
union all select 5,3
union all select 5,2
select a,min(b)b from @b group by a
/*
day &nbs