Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

SELECT statement

$
0
0

This SELECT statement works fine with MS Access 

SELECT MAX(FORMAT(exam_date, 'yyyymmdd') & RIGHT("000" & exam_seq, 3)) 
FROM (SELECT exam_date, exam_seq FROM surgical_exam WHERE patient_id=1 
UNION ALL SELECT exam_date, exam_seq FROM surgical_exam_record WHERE patient_id=1)

However, error occurs from following SELECT statement  with SQL Server.

SELECT MAX(CONVERT(VARCHAR(8), exam_date, 112) + RIGHT('000' + exam_seq, 3)) 
FROM (SELECT exam_date, exam_seq FROM surgical_exam WHERE patient_id=1 
UNION ALL SELECT exam_date, exam_seq FROM surgical_exam_record WHERE patient_id=1)
How can I solve this problem?

Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>