do it in the database, use left outer join
解决方案 »
- 新手问list的元素如何access
- 如何实现dataGridView1批量更新数据?
- WPF: WindowsFormsHost通过Child内容刷新,闪屏的问题!!!!!!!
- 我正在做一个车辆定位系统,我需要通过GPRS从车载的GPS拿到汽车的坐标,写到数据库中,要购买哪款GPS设备才能实现我的需求。
- 紧急求救
- 如何获取动态添加的控件name?
- [DataGridView排序]怎样与其数据源DataSet同步
- 请高手指教:在web下怎样用javascript向listbox中添加或删除所选定的项!
- ZengHD你在哪里 求教:改变listview virtualmodel下 子项的位置
- 在框架中如何传值,并有反应
- 《设计模式》书中提到的"C++ don't treat classes as first-class objects"是什么意思?
- (((Sos)))在WebForm中如何拦截对所有LinkButton的单击消息,并判断鼠标点了哪个LinkButton
select CpsHseId,dbo.FunGetCurYM(CpsHseId,'2002','8','未收') as '所含时间',sum(case CpsStatus when '未收' then CpsTotalPrice else 0 end) from Twy_ChargePays where CpsHseId=25760 group by CpsHseId
2、函数:取得当月以前费用发生年月及金额*/
/*drop function FunGetCurYM*/
CREATE FUNCTION FunGetCurYM(@CpsHseId nvarchar(10),@YearS nvarchar(4),@MonthS nvarchar(2),@CpsStatus nvarchar(10))
RETURNS nvarchar(500)
as
begin
declare @YMValue nvarchar(50)
declare @Value nvarchar(500)
set @YMValue=''
set @Value =''
if len(rtrim(ltrim(@MonthS)))<2
begin
set @MonthS='0'+@MonthS
end
declare YMList cursor for
select CpsDate from Twy_ChargePays
where ceiling(CpsYear+case when len(ltrim(rtrim(CpsMonth)))<2 then '0'+CpsMonth else CpsMonth end) <=ceiling(@YearS+@MonthS)
and CpsHseId=@CpsHseId and CpsStatus=@CpsStatus order by ceiling(CpsYear+case when len(ltrim(rtrim(CpsMonth)))<2 then '0'+CpsMonth else CpsMonth end)
open YMList
fetch next from YMList into @YMValue
while @@Fetch_Status = 0
begin
set @Value=case when len(ltrim(rtrim(@YMValue)))>0 then @Value+' '+@YMValue else @YMValue end
set @YMValue=''
fetch next from YMList into @YMValue
end
close YMList
deallocate YMList
return(@Value)
end 自定义函数取得发生费用的时间资料太慢,也不是个好办法。我就是想请教你把结果集的列集合并入另一集合作为行中字段的方法。
连呼1000000声谢谢。