62,046
社区成员
发帖
与我相关
我的任务
分享
select distinct (f.carno), g.drivername, f.cartype, g.phoneno, g.company
from bd_car f, bd_driver g, bd_caranddriver h, BD_CAR_SCHEDULE e,app_main a
where a.appno='XXXX'--取前台传的单号
and f.carno = h.carno
and g.drivername = h.drivername
and e.carno = f.carno
and h.isvalid = '1'
and e.sdate=a.appdt--日期
and e.sflag='N'
and rownum=1
a.appno=@appno
然后这个@appno通过SqlParameter传递
string mainsql = @"select distinct (t.carno)
from BD_CAR_SCHEDULE t,app_main a
where t.sdate=a.appdt and a.appno='"+appNo+@"' and t.timestart between a.ride_starttime and a.ride_backtime
and not exists(select 0 from BD_CAR_SCHEDULE x where x.carno=t.carno and x.sdate=t.sdate and x.timestart between a.ride_starttime and a.ride_backtime and x.sflag='Y')";
我记得+appNo+这样写不好,应该怎么写declare @ride_starttime nvarchar(50)='2017-05-19 23:00:00', --出发时间
@estimatetime int=2 --所用时间
select
id,
name,
sdate,
timestart,
(case when dateadd(hh,2,CONVERT(varchar(100), @ride_starttime, 20))< CONVERT(varchar(100), sdate+' '+timestart, 20) then 1 else 0 end) sflag
from test