Views
No views yet
<|im_start|>system
You are a Couchbase SQL++ query expert. Given a database schema and a natural language question, generate a syntactically valid SQL++ query that precisely answers the question.
Rules:
- SELECT only the columns explicitly asked for — nothing more, nothing less
- Use the exact bucket, scope, and collection names provided in the schema
Output Format:
In your answer, please enclose the generated SQL++ query in a code block:<|im_end|>
<|im_start|>user
Bucket Name:
`bird_training_bucket`
Scope Name:
`books`
Database Schema:
{"`bird_training_bucket`.`books`.`order_line`": {"properties": {"book_id": {"samples": [3103], "type": "number"}, "line_id": {"samples": [1849], "type": "number"}, "order_id": {"samples": [306], "type": "number"}, "price": {"samples": [3.68], "type": "number"}}, "type": "object"}, "`bird_training_bucket`.`books`.`order_history`": {"properties": {"history_id": {"samples": [1203], "type": "number"}, "order_id": {"samples": [515], "type": "number"}, "status_date": {"samples": ["2020-04-15 00:45:35"], "type": "string"}, "status_id": {"samples": [1], "type": "number"}}, "type": "object"}, "`bird_training_bucket`.`books`.`sqlite_sequence`": {"properties": {"name": {"samples": ["cust_order"], "type": "string"}, "seq": {"samples": [8573], "type": "number"}}, "type": "object"}, "`bird_training_bucket`.`books`.`cust_order`": {"properties": {"customer_id": {"samples": [184], "type": "number"}, "dest_address_id": {"samples": [50], "type": "number"}, "order_date": {"samples": ["2019-12-10 07:09:28"], "type": "string"}, "order_id": {"samples": [1465], "type": "number"}, "shipping_method_id": {"samples": [1], "type": "number"}}, "type": "object"}, "`bird_training_bucket`.`books`.`shipping_method`": {"properties": {"cost": {"samples": [5.9], "type": "number"}, "method_id": {"samples": [1], "type": "number"}, "method_name": {"samples": ["Express"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`book_author`": {"properties": {"author_id": {"samples": [290], "type": "number"}, "book_id": {"samples": [680], "type": "number"}}, "type": "object"}, "`bird_training_bucket`.`books`.`book`": {"properties": {"book_id": {"samples": [1267], "type": "number"}, "isbn13": {"samples": ["9780140620122"], "type": "string"}, "language_id": {"samples": [1], "type": "number"}, "num_pages": {"samples": [279], "type": "number"}, "publication_date": {"samples": ["1982-05-06"], "type": "string"}, "publisher_id": {"samples": [282], "type": "number"}, "title": {"samples": ["Must Love Dragons (Immortally ..."], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`publisher`": {"properties": {"publisher_id": {"samples": [1304], "type": "number"}, "publisher_name": {"samples": ["Museum of Modern Art"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`order_status`": {"properties": {"status_id": {"samples": [1], "type": "number"}, "status_value": {"samples": ["Cancelled"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`customer_address`": {"properties": {"address_id": {"samples": [130], "type": "number"}, "customer_id": {"samples": [460], "type": "number"}, "status_id": {"samples": [1], "type": "number"}}, "type": "object"}, "`bird_training_bucket`.`books`.`customer`": {"properties": {"customer_id": {"samples": [143], "type": "number"}, "email": {"samples": ["fbachellier7p@wired.com"], "type": "string"}, "first_name": {"samples": ["Fonzie"], "type": "string"}, "last_name": {"samples": ["Bachellier"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`address`": {"properties": {"address_id": {"samples": [121], "type": "number"}, "city": {"samples": ["Dokolo"], "type": "string"}, "country_id": {"samples": [42], "type": "number"}, "street_name": {"samples": ["Del Mar Trail"], "type": "string"}, "street_number": {"samples": ["0"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`country`": {"properties": {"country_id": {"samples": [1], "type": "number"}, "country_name": {"samples": ["Afghanistan"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`book_language`": {"properties": {"language_code": {"samples": ["fre"], "type": "string"}, "language_id": {"samples": [3], "type": "number"}, "language_name": {"samples": ["French"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`author`": {"properties": {"author_id": {"samples": [732], "type": "number"}, "author_name": {"samples": ["Ben Shahn"], "type": "string"}}, "type": "object"}, "`bird_training_bucket`.`books`.`address_status`": {"properties": {"address_status": {"samples": ["Active"], "type": "string"}, "status_id": {"samples": [1], "type": "number"}}, "type": "object"}}
This schema describes the structure of the data in the specified bucket and scope. It includes information about the collections, fields, and their data types.
Question:
How many books were ordered by customer Kandy Adamec?
<|im_end|>
<|im_start|>assistantbird_training_bucket.books.order_line AS T1 INNER JOIN bird_training_bucket.books.cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN bird_training_bucket.books.customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Kandy' AND T3.last_name = 'Adamec'<|im_end|>