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:
`training_bucket`
Scope Name:
`Professional_Sports_League_Administration_scope`
Database Schema:
{"`training_bucket`.`Professional_Sports_League_Administration_scope`.`disciplinary_cases`": {"properties": {"allegations": {"samples": ["Great mean rather buy intervie..."], "type": "string"}, "case_number": {"samples": ["AGH-2026-8794"], "type": "string"}, "created_at": {"samples": ["2025-07-24T04:25:06.596694Z"], "type": "string"}, "evidence": {"items": {"properties": {"added_at": {"samples": ["2025-07-30T16:09:46.217182Z"], "type": "string"}, "added_by_staff_member_id": {"samples": ["staff_0cddfcfc-0038-42e0-9e09-..."], "type": "string"}, "type": {"samples": ["document"], "type": "string"}, "uri": {"samples": ["https://brown.net/president-ex..."], "type": "string"}}, "type": "object"}, "samples": [{"added_at": "2025-07-30T16:09:46.217182Z", "added_by_staff_member_id": "staff_e6c61444-efa0-4ca9-83db-6b870db328dc", "type": "photo", "uri": "https://bryan-thompson.org/why-second-sound/de18f9fa-833c-4b43-942c-e53d62b6ae86"}], "type": "array"}, "incident_date": {"samples": ["2025-05-31"], "type": "string"}, "league_id": {"samples": ["league_1357e235-29a5-492d-a648..."], "type": "string"}, "outcome": {"properties": {"decision_date": {"samples": ["2025-09-19"], "type": "string"}, "sanctions": {"items": {"properties": {"amount": {"type": "number"}, "currency": {"type": "string"}, "effective_range": {"properties": {"end_date": {"type": "string"}, "start_date": {"type": "string"}}, "type": "object"}, "games_suspended": {"type": "number"}, "notes": {"type": "string"}, "type": {"type": "string"}}, "type": "object"}, "samples": [{"type": "warning"}], "type": "array"}}, "type": "object"}, "related_game_id": {"samples": ["game_07af317d-3794-4177-a460-7..."], "type": "string"}, "rule_citations": {"items": {"type": "string"}, "samples": ["Rule 11.6"], "type": "array"}, "season_id": {"samples": ["season_159c9660-0b17-4bca-9aff..."], "type": "string"}, "status": {"samples": ["closed"], "type": "string"}, "subject": {"properties": {"entity_type": {"samples": ["player"], "type": "string"}, "player_id": {"samples": ["player_9e6b1092-9386-4a8b-ae8a..."], "type": "string"}, "staff_member_id": {"samples": ["staff_969ac330-45db-4bc3-a8fa-..."], "type": "string"}, "team_id": {"samples": ["team_01bc97c0-d2da-46ed-acb8-7..."], "type": "string"}}, "type": "object"}, "updated_at": {"samples": ["2025-08-19T04:52:06.455483Z"], "type": "string"}, "workflow": {"items": {"properties": {"changed_at": {"samples": ["2025-09-18T17:10:14.596681Z"], "type": "string"}, "changed_by_staff_member_id": {"samples": ["staff_0827a937-b1d8-4ab4-b331-..."], "type": "string"}, "note": {"samples": ["Front cover that contain throu..."], "type": "string"}, "state": {"samples": ["closed"], "type": "string"}}, "type": "object"}, "samples": [{"changed_at": "2025-09-02T07:10:14.596681Z", "note": "Upon thing official leave next wide figure down some.", "state": "reported"}], "type": "array"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`standings`": {"properties": {"as_of_utc": {"samples": ["2025-09-16T03:47:00.140569Z"], "type": "string"}, "competition_id": {"samples": ["competition_59654ad8-beea-46db..."], "type": "string"}, "created_at": {"samples": ["2025-07-01T01:49:45.153525Z"], "type": "string"}, "league_id": {"samples": ["league_284e87bc-dc22-41f4-a3fe..."], "type": "string"}, "scope": {"samples": ["conference"], "type": "string"}, "season_id": {"samples": ["season_1c2d0ef6-174c-42a6-a5b1..."], "type": "string"}, "table": {"items": {"properties": {"draws": {"samples": [0], "type": "number"}, "last_n": {"properties": {"draws": {"type": "null"}, "losses": {"samples": [0], "type": "number"}, "n": {"samples": [5], "type": "number"}, "wins": {"samples": [0], "type": "number"}}, "samples": [{"losses": 0, "n": 5, "wins": 1}], "type": ["object", "object"]}, "losses": {"samples": [0], "type": "number"}, "played": {"samples": [1], "type": "number"}, "point_diff": {"samples": [-1520], "type": "number"}, "points": {"samples": [0], "type": "number"}, "points_against": {"samples": [1220], "type": "number"}, "points_for": {"samples": [188], "type": "number"}, "rank": {"samples": [2], "type": "number"}, "streak": {"samples": ["L7"], "type": "string"}, "team_id": {"samples": ["team_47845eb2-cda9-4a7e-84d4-7..."], "type": "string"}, "wins": {"samples": [0], "type": "number"}}, "type": "object"}, "samples": [{"losses": 1, "played": 64, "points": 126, "points_against": 5013, "points_for": 5293, "rank": 1, "streak": "L3", "team_id": "team_c903cb51-45ba-4324-b055-4fed8e9e01f3", "wins": 63}], "type": "array"}, "updated_at": {"samples": ["2025-07-12T01:33:41.153525Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`games`": {"properties": {"attendance": {"samples": [3451], "type": "number"}, "away_team_id": {"samples": ["team_092575ea-b078-484d-ab86-f..."], "type": "string"}, "competition_id": {"samples": ["competition_1c0ed565-0b07-437e..."], "type": "string"}, "created_at": {"samples": ["2025-06-23T01:48:47.095243Z"], "type": "string"}, "home_team_id": {"samples": ["team_553d2828-2e63-41ea-882a-9..."], "type": "string"}, "league_id": {"samples": ["league_2d024e05-0abe-460b-8400..."], "type": "string"}, "officials": {"items": {"properties": {"role": {"type": "string"}, "staff_member_id": {"type": "string"}}, "type": "object"}, "samples": [{"role": "judge", "staff_member_id": "staff_6ee32da6-b159-4d98-9656-39d9f5cc52bd"}], "type": "array"}, "result": {"properties": {"away_score": {"samples": [0], "type": "number"}, "ended_at_utc": {"samples": ["2023-06-21T09:44:00Z"], "type": "string"}, "home_score": {"samples": [0], "type": "number"}, "periods": {"items": {"properties": {"away": {"type": "number"}, "home": {"type": "number"}, "label": {"type": "string"}}, "type": "object"}, "samples": [{"away": 0, "home": 0, "label": "H1"}], "type": "array"}, "winner_team_id": {"samples": ["team_13302ff2-8938-4fac-accd-1..."], "type": "string"}}, "type": "object"}, "scheduled_start_utc": {"samples": ["2023-06-21T05:15:00Z"], "type": "string"}, "season_id": {"samples": ["season_14aa78d7-2c2e-4335-b4e9..."], "type": "string"}, "status": {"samples": ["cancelled"], "type": "string"}, "time_zone": {"samples": ["America/Denver"], "type": "string"}, "updated_at": {"samples": ["2025-07-30T20:26:57.095243Z"], "type": "string"}, "venue_id": {"samples": ["venue_08e12f1a-52e8-4220-aa7a-..."], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`competitions`": {"properties": {"competition_type": {"samples": ["cup"], "type": "string"}, "created_at": {"samples": ["2025-03-11T09:05:29.785272Z"], "type": "string"}, "format": {"properties": {"group_stage": {"samples": [false], "type": "boolean"}, "num_teams": {"samples": [10], "type": "number"}, "series_best_of": {"samples": [1], "type": "number"}, "tiebreaker_rules": {"samples": ["goal difference"], "type": "string"}}, "type": "object"}, "league_id": {"samples": ["league_0365d5fe-edfa-46ef-9224..."], "type": "string"}, "name": {"samples": ["KOU 2025 Tournament Competitio..."], "type": "string"}, "season_id": {"samples": ["season_3ae93667-210f-4ecf-950a..."], "type": "string"}, "status": {"samples": ["active"], "type": "string"}, "updated_at": {"samples": ["2025-03-27T08:50:10.795227Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`contracts`": {"properties": {"clauses": {"items": {"type": "string"}, "samples": ["injury_protection"], "type": "array"}, "compensation": {"properties": {"base_salary": {"samples": [2339703], "type": "number"}, "bonuses": {"items": {"properties": {"amount": {"type": "number"}, "criteria": {"type": "string"}, "type": {"type": "string"}}, "type": "object"}, "samples": [{"amount": 497631.82, "type": "signing"}], "type": "array"}, "cap_hit": {"samples": [2464110.96], "type": "number"}, "currency": {"samples": ["CAD"], "type": "string"}, "incentives": {"items": {"properties": {"achieved": {"type": "boolean"}, "amount": {"type": "number"}, "description": {"type": "string"}}, "type": "object"}, "samples": [{"amount": 2125162.38, "description": "Help season difficult it class industry despite within Mrs."}], "type": "array"}}, "type": "object"}, "contract_type": {"samples": ["loan"], "type": "string"}, "created_at": {"samples": ["2024-05-20T19:40:40.798009Z"], "type": "string"}, "league_id": {"samples": ["league_0522cb78-91a7-4d8c-bdc4..."], "type": "string"}, "player_id": {"samples": ["player_34f9d98c-95dc-4264-827d..."], "type": "string"}, "season_id": {"samples": ["season_2e33613b-7130-4013-9a81..."], "type": "string"}, "status": {"samples": ["active"], "type": "string"}, "team_id": {"samples": ["team_1333c6ba-fc4f-441c-8573-7..."], "type": "string"}, "term": {"properties": {"end_date": {"samples": ["2024-06-19"], "type": "string"}, "guaranteed": {"samples": [false], "type": "boolean"}, "signed_date": {"samples": ["2023-01-01"], "type": "string"}, "start_date": {"samples": ["2023-05-02"], "type": "string"}}, "type": "object"}, "updated_at": {"samples": ["2024-08-07T09:26:43.798009Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`team_season_rosters`": {"properties": {"as_of_date": {"samples": ["2024-05-31"], "type": "string"}, "created_at": {"samples": ["2025-04-18T01:42:28.047598Z"], "type": "string"}, "notes": {"samples": ["Great occur store economy then..."], "type": "string"}, "players": {"items": {"properties": {"contract_id": {"type": "null"}, "effective_range": {"properties": {"end_date": {"samples": ["2023-08-20"], "type": "string"}, "start_date": {"samples": ["2023-07-04"], "type": "string"}}, "type": "object"}, "jersey_number": {"samples": ["15"], "type": "string"}, "player_id": {"samples": ["player_589d9923-249a-48c2-9ea6..."], "type": "string"}, "positions": {"items": {"type": "string"}, "samples": ["1B"], "type": "array"}, "roster_status": {"samples": ["active"], "type": "string"}, "two_way": {"type": "null"}}, "type": "object"}, "samples": [{"jersey_number": "19", "player_id": "player_fb47387a-b5be-416e-8f69-cb414d448f0e", "roster_status": "active"}], "type": "array"}, "season_id": {"samples": ["season_7961d060-054c-4f33-9266..."], "type": "string"}, "team_id": {"samples": ["team_34a3102e-3fc0-4fd8-8866-a..."], "type": "string"}, "updated_at": {"samples": ["2025-05-06T07:20:18.047598Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`staff_members`": {"properties": {"contact": {"properties": {"email": {"samples": ["christineeverett@example.net"], "type": "string"}, "phone": {"samples": ["(228)348-5207"], "type": "string"}}, "type": "object"}, "created_at": {"samples": ["2024-05-03T17:24:51.689642Z"], "type": "string"}, "department": {"samples": ["Analytics"], "type": "string"}, "employment_type": {"samples": ["contract"], "type": "string"}, "full_name": {"samples": ["Donald Walter"], "type": "string"}, "league_id": {"samples": ["league_3e23e436-77ad-42aa-b66a..."], "type": "string"}, "role": {"samples": ["Commissioner"], "type": "string"}, "status": {"samples": ["active"], "type": "string"}, "team_id": {"samples": ["team_10190d7b-0b17-4a55-922a-d..."], "type": "string"}, "updated_at": {"samples": ["2024-05-13T16:38:54.689642Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`players`": {"properties": {"agent": {"properties": {"agency": {"samples": ["Freeman, Vargas and Matthews"], "type": "string"}, "email": {"samples": ["ftucker@example.net"], "type": "string"}, "name": {"samples": ["Elizabeth White"], "type": "string"}, "phone": {"samples": ["551-987-6246x4130"], "type": "string"}}, "samples": [{"agency": "Freeman, Vargas and Matthews", "email": "stephaniehampton@example.net", "name": "Elizabeth White", "phone": "956-351-7358x92908"}], "type": ["object", "object", "object", "object", "object", "object", "object", "object"]}, "created_at": {"samples": ["2024-05-04T13:04:25.166629Z"], "type": "string"}, "date_of_birth": {"samples": ["1997-02-14"], "type": "string"}, "first_name": {"samples": ["Beverly"], "type": "string"}, "full_name": {"samples": ["Jason Krause"], "type": "string"}, "identifiers": {"properties": {"external_player_id": {"samples": ["5994c97c-dfc3-47b3-95e1-18be31..."], "type": "string"}, "government_id_hash": {"samples": ["93ab72f33941fe1566bf9ab5497c0d..."], "type": "string"}}, "type": "object"}, "last_name": {"samples": ["Hodge"], "type": "string"}, "nationality": {"samples": ["Colombia"], "type": "string"}, "physical": {"properties": {"height_cm": {"samples": [178], "type": "number"}, "weight_kg": {"samples": [70], "type": "number"}}, "type": "object"}, "positions": {"items": {"type": "string"}, "samples": ["DH"], "type": "array"}, "preferred_position": {"samples": ["D"], "type": "string"}, "status": {"samples": ["active"], "type": "string"}, "updated_at": {"samples": ["2024-08-15T02:31:23.166629Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`venues`": {"properties": {"address": {"properties": {"city": {"samples": ["New Peter"], "type": "string"}, "country": {"samples": ["Eritrea"], "type": "string"}, "line1": {"samples": ["7163 Smith Ridge Apt. 766"], "type": "string"}, "line2": {"samples": ["Apt. 126"], "type": "string"}, "postal_code": {"samples": ["33200"], "type": "string"}, "region": {"samples": ["Idaho"], "type": "string"}}, "type": "object"}, "amenities": {"items": {"type": "string"}, "samples": ["concessions"], "type": "array"}, "capacity": {"samples": [10065], "type": "number"}, "created_at": {"samples": ["2023-11-11T22:28:55.162426Z"], "type": "string"}, "geo": {"properties": {"lat": {"samples": [-7.349485], "type": "number"}, "lon": {"samples": [-13.069704], "type": "number"}}, "type": "object"}, "name": {"samples": ["Ellis Park"], "type": "string"}, "surface": {"samples": ["clay"], "type": "string"}, "time_zone": {"samples": ["America/Denver"], "type": "string"}, "type": {"samples": ["arena"], "type": "string"}, "updated_at": {"samples": ["2024-04-02T11:54:52.162426Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`teams`": {"properties": {"branding": {"properties": {"logo_url": {"samples": ["https://barr-cline.biz/logos/t..."], "type": "string"}, "primary_color": {"samples": ["#492AE7"], "type": "string"}, "secondary_color": {"samples": ["#B780D0"], "type": "string"}}, "type": "object"}, "city": {"samples": ["Douglasmouth"], "type": "string"}, "country": {"samples": ["American Samoa"], "type": "string"}, "created_at": {"samples": ["2024-05-21T00:31:46.854079Z"], "type": "string"}, "home_venue_id": {"samples": ["venue_385671b6-0b7b-43dc-a1c3-..."], "type": "string"}, "league_id": {"samples": ["league_423f0d07-9dd4-4f81-bff1..."], "type": "string"}, "name": {"samples": ["Jacquelinetown"], "type": "string"}, "nickname": {"samples": ["Eagles"], "type": "string"}, "ownership": {"properties": {"contact_email": {"samples": ["adamgregory@morse.info"], "type": "string"}, "ownership_group": {"samples": ["Mejia-Diaz"], "type": "string"}, "principal_owner_name": {"samples": ["Amanda Beard"], "type": "string"}}, "type": "object"}, "region": {"samples": ["Louisiana"], "type": "string"}, "status": {"samples": ["active"], "type": "string"}, "updated_at": {"samples": ["2024-09-30T01:53:38.854079Z"], "type": "string"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`seasons`": {"properties": {"created_at": {"samples": ["2023-08-07T03:36:04.769274Z"], "type": "string"}, "date_range": {"properties": {"end_date": {"samples": ["2024-04-28"], "type": "string"}, "start_date": {"samples": ["2024-03-26"], "type": "string"}}, "type": "object"}, "league_id": {"samples": ["league_3396dac0-1b84-444a-bf8f..."], "type": "string"}, "name": {"samples": ["2026 ANB Regular Season"], "type": "string"}, "roster_rules": {"properties": {"active_roster_max": {"samples": [18], "type": "number"}, "active_roster_min": {"samples": [15], "type": "number"}, "currency": {"samples": ["CAD"], "type": "string"}, "designated_player_slots": {"samples": [0], "type": "number"}, "salary_cap_amount": {"samples": [59323118], "type": "number"}, "salary_floor_amount": {"samples": [47150293], "type": "number"}}, "type": "object"}, "season_type": {"samples": ["playoffs"], "type": "string"}, "status": {"samples": ["active"], "type": "string"}, "updated_at": {"samples": ["2023-10-25T12:12:34.768501Z"], "type": "string"}, "year": {"samples": [2023], "type": "number"}}, "type": "object"}, "`training_bucket`.`Professional_Sports_League_Administration_scope`.`leagues`": {"properties": {"abbreviation": {"samples": ["FBR"], "type": "string"}, "country": {"samples": ["American Samoa"], "type": "string"}, "created_at": {"samples": ["2023-05-09T08:27:21.278502Z"], "type": "string"}, "founded_year": {"samples": [1932], "type": "number"}, "governance": {"properties": {"commissioner_staff_member_id": {"samples": ["staff_5f5b698e-318d-4f2a-a75b-..."], "type": "string"}, "contacts": {"items": {"properties": {"is_primary": {"type": "boolean"}, "type": {"type": "string"}, "value": {"type": "string"}}, "type": "object"}, "samples": [{"is_primary": false, "type": "phone", "value": "001-530-610-2724x0559"}], "type": "array"}, "headquarters": {"properties": {"city": {"samples": ["Elizabethbury"], "type": "string"}, "country": {"samples": ["American Samoa"], "type": "string"}, "line1": {"samples": ["0119 Jennifer Springs Apt. 075"], "type": "string"}, "line2": {"samples": ["Apt. 253"], "type": "string"}, "postal_code": {"samples": ["06332"], "type": "string"}, "region": {"samples": ["Arizona"], "type": "string"}}, "type": "object"}}, "type": "object"}, "name": {"samples": ["Brownbury American Football Le..."], "type": "string"}, "rules_url": {"samples": ["https://burgess.org/rules/espe..."], "type": "string"}, "sport": {"samples": ["American Football"], "type": "string"}, "status": {"samples": ["active"], "type": "string"}, "updated_at": {"samples": ["2023-06-03T00:50:04.278502Z"], "type": "string"}}, "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:
Find disciplinary cases involving a player where the related game was finalized and had very high attendance, and show the case number, the winning team, and the list of rule citations attached to that case.
<|im_end|>
<|im_start|>assistantcase_number, g.result.winner_team_id AS winning_team_id, dc.rule_citations FROM training_bucket.Professional_Sports_League_Administration_scope.disciplinary_cases AS dc JOIN training_bucket.Professional_Sports_League_Administration_scope.games AS g ON META(g).id = dc.related_game_id WHERE dc.subject.entity_type = "player" AND g.status = "final" AND g.attendance >= 15000 ORDER BY dc.case_number;<|im_end|>