Find the names of all procedures such that the cost is less than 5000 and physician John Wen was trained in.
CREATE TABLE trained_in (physician VARCHAR, treatment VARCHAR); CREATE TABLE procedures (name VARCHAR, cost INTEGER); CREATE TABLE physician (employeeid VARCHAR, name VARCHAR); CREATE TABLE procedures (name VARCHAR, code VARCHAR)
SELECT name FROM procedures WHERE cost < 5000 INTERSECT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen"
<s>[INST] Write mssql query to answer the following question given the database schema. Schema: CREATE TABLE trained_in (physician VARCHAR, treatment VARCHAR); CREATE TABLE procedures (name VARCHAR, cost INTEGER); CREATE TABLE physician (employeeid VARCHAR, name VARCHAR); CREATE TABLE procedures (name VARCHAR, code VARCHAR) Question: Find the names of all procedures such that the cost is less than 5000 and physician John Wen was trained in. [/INST] SELECT name FROM procedures WHERE cost < 5000 INTERSECT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen" </s>