本文介绍了sql2005中的sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以说这0和一个1在GPS_DATETIME附近在做什么,以及是否插入了值
can any one say what does this 0 and one 1 does here near the GPS_DATETIME and also whether the values get inserted
insert into @temp
SELECT REGISTRATIONNO,GPS_DATETIME,SPEED,
CASE WHEN BASESTATIONNAME IS NULL THEN LOCATION ELSE BASESTATIONNAME END AS LOCATION,
LAT_METER,LON_METER,ODOMETER
FROM GPSDATA_HISTORY
WHERE
GPS_DATETIME BETWEEN @v_from_date AND @v_to_date
and registrationno=@v_reg_no
union
select REGISTRATIONNO,GPS_DATETIME,SPEED,
LOCATION,
LAT_METER,LON_METER,ODOMETER from (SELECT TOP 1 REGISTRATIONNO,GPS_DATETIME,1 as speed,
CASE WHEN BASESTATIONNAME IS NULL THEN LOCATION ELSE BASESTATIONNAME END AS LOCATION,
LAT_METER,LON_METER,ODOMETER
FROM GPSDATA_HISTORY
WHERE GPS_DATETIME BETWEEN @v_from_date AND @v_to_date
and registrationno=@v_reg_no order by gps_Datetime desc)b
union
select REGISTRATIONNO,GPS_DATETIME,SPEED,
LOCATION,
LAT_METER,LON_METER,ODOMETER from (SELECT TOP 1 REGISTRATIONNO,GPS_DATETIME,0 as speed,
CASE WHEN BASESTATIONNAME IS NULL THEN LOCATION ELSE BASESTATIONNAME END AS LOCATION,
LAT_METER,LON_METER,ODOMETER
FROM GPSDATA_HISTORY
WHERE GPS_DATETIME BETWEEN @v_from_date AND @v_to_date
and registrationno=@v_reg_no order by gps_Datetime desc)c
推荐答案
这篇关于sql2005中的sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!