What am I doing wrong here? I am getting this error on:
SELECT LEFT(SUBSTRING(batchinfo.datapath, PATINDEX(\'%[0-9][0-9][0-9]%\', batchinfo.datapath), 8000),
Here's a simple query to find company name who has a medicine type of A and makes more than 2.
SELECT CNAME FROM COMPANY WHERE CNO IN ( SELECT CNO FROM MEDICINE WHERE type='A' GROUP BY CNO HAVING COUNT(type) > 2 )