运行此 SQL 时出现此错误。
我的错误消息是:
Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to bigint.
SELECT k.hit,
k.reach,
CONVERT(VARCHAR(20), j.signon_date,101) AS dispatch_date,
i.name AS agency_name,
i.name,
a.id,
a.pps_id,
a.brand_id,
CONVERT(VARCHAR(20), a.[date],101) AS [date],
b.id AS pome_route_detail_id,
b.route_id,
z.outlet_code as barangay_id,
b.reach,
l.name AS region_name,
e.name AS province_name,
d.name AS municipal_name,
z.outlet_name AS barangay_name,
c.[population],
c.household,
c._ph_id,
z.lattitude AS latitude,
z.longtitude AS longitude,
f.name AS team_name,
f.teamCode,
g.name AS brand_name,
CASE j.[status]
WHEN 1 THEN 'ACTIVE'
WHEN 2 THEN 'CLOSED'
WHEN 3 THEN 'BASE PREPARATION'
WHEN 4 THEN 'CANCELLED'
ELSE 'NOT REPORTED'
END AS dispatch_status,
a.[date] AS formatted_date,CONVERT(VARCHAR(20),
k.[start_date],101) AS start_date
from dbo.pome_route_transaction_detail AS k
INNER join dbo.pome_route_transaction AS j ON j.id = k.pome_route_transaction_id
and j.status !=4 and k.status = 1
INNER join dbo.pome_route AS a on a.id = j.route_id
left join dbo.pome_route_details AS b ON a.id = b.route_id and b.[hospital_id] = k. [pome_hospital_id]
INNER JOIN dbo.outlets AS z ON z.outlet_code = k.pome_hospital_id
INNER JOIN dbo.barangay AS c ON c.id = z.barangay_id
INNER JOIN dbo.municipal AS d ON d.id = c.municipal_id
INNER JOIN dbo.province AS e ON e.id = d.province_id
INNER JOIN dbo.region AS l ON l.id = e.region_id
INNER JOIN dbo.team AS f ON f.id = a.pps_id
INNER JOIN dbo.brand AS g ON g.id = a.brand_id
INNER JOIN dbo.agency_team AS h ON h.team_id = f.id
INNER JOIN dbo.agency AS i ON i.id = h.agency_id
我包括了 from 子句和连接。Where 子句是 Where a.[date] = '07/25/2013' 感谢各位的帮助!我把所有的代码都放在这里嘿嘿嘿