你能幫助這兩個查詢嗎?加入sql查詢
查詢之一:
declare @startdate datetime
declare @enddate datetime
set @datainicio='2014-03-01'
set @datafim='2014-03-03'
select right([Location Code],4) as Vehicle,MIN(CAST(CAST([date]AS DATE) AS DATETIME) +
CAST([entry time]AS TIME)) as DaeaMin,min([Veihicle Kms]) as KmsMin,MAX(CAST(CAST([date]AS DATE) AS DATETIME) +
CAST([entry time]AS TIME)) as DateMax,max([Veihicle Kms])as KmsMax
where quantity>=0 and [Location code] like 'v%' and [item no_]='601.0001' and ([date] between @startdate and @enddate)
group by [Location Code]
查詢二:
SELECT Vehicles.Designation as Vehicle,
SUM(Locations.DistanceFromLastLocation)/1000 as
KMS,convert(varchar(10),LocationDate,120) as Date
FROM Locations INNER JOIN Vehicles ON Locations.VehicleId = Vehicles.VehicleId
GROUP BY Vehicles.Designation,LocationDate
我想加入這兩個查詢的車輛和查詢兩個日期必須是從查詢一個datemin和datemax之間。
幫助,謝謝。
你在MySQL中做了很多*什麼? – Rachcha
第一個查詢中的FROM子句在哪裏? – Prashant16
我們可以得到一些樣本起始數據和期望的結果嗎?無論如何,我們都需要缺少'FROM'子句/表引用。 –