Can you guys guide me as to why this does not work?
SELECT AN.an_id, AN.an_name,
(SELECT TOP(1)ex_date
FROM upd_exam_headers
WHERE HS.an_id = AN.an_id
ORDER BY ex_date desc),
sum(ex_fee)
INTO upd_nc_felines AS FS
FROM upd_animals AS AN
LEFT JOIN upd_exam_headers AS HS ON HS.an_id = AN.an_id
LEFT JOIN upd_exam_details AS DS ON DS.ex_id = HS.ex_id
WHERE an_type = 'cat' and an_status = 'NC'
GROUP BY AN.an_id, AN.an_name;
Msg 156, Level 15, State 1, Line 10 Incorrect syntax near the keyword 'AS'.
The error message says what it means :)
Add an alias to sum(ex_fee)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With