system stringlengths 315 8.06k | conversations listlengths 2 48 |
|---|---|
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE smart_money_token_inflow ( token_address.text, token_symbol.text, token_amount.numeric, usd_value.numeric, avg_price.numeric, type.numeric, address_amount.numeric, narrative.text, chain.text )
| [
{
"role": "user",
"content": "What is the average USD value per address for each narrative across all chains?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT\n narrative,\n AVG(usd_value / NULLIF(address_amount, 0)) AS avg_usd_per_address\nFROM smart_money_token_inflow\nGROUP BY... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE insurance.insurance_products ( product_id text PRIMARY KEY, product_name text, product_type text, description text, base_premium numeric, coverage_details text, underwriting_rules text, is_active boolean, created_at timestamp, updated_at timestamp )
| [
{
"role": "user",
"content": "Get the number of insurance products grouped by product_type and their active status. Return product_type, is_active, and the count of products.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT product_type, is_active, COUNT(*) AS product_count\nFROM i... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE legal_services.documents ( document_id.text, case_id.text, document_name.text, document_type.text, storage_path.text, uploaded_by_lawyer_id.text, upload_timestamp.timestamp, version.integer, description.text )
| [
{
"role": "user",
"content": "Find documents that have the same document_name but are associated with different cases. Show the document name and the two different case IDs.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT d1.document_name, d1.case_id AS case_id_1, d2.case_id AS ca... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE social_media.posts ( post_id text PRIMARY KEY, user_id text, content text, media_url text, media_type text, created_at timestamp, updated_at timestamp, visibility text, location_lat numeric, location_lon numeric )
| [
{
"role": "user",
"content": "List all posts where the content mentions 'meeting'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT post_id, user_id, content, created_at FROM social_media.posts WHERE content LIKE '%meeting%'",
"sql": null
},
{
"role": "user",
"conte... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE social_media.users ( user_id character varying(64) NOT NULL, username character varying(50) NOT NULL UNIQUE, email character varying(128) NOT NULL UNIQUE, password_hash text NOT NULL, full_name character varying(100), profile_picture_url text, bio text, location character varying(100), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, is_verified boolean NOT NULL DEFAULT false, PRIMARY KEY (user_id) )
CREATE TABLE social_media.comments ( comment_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, parent_comment_id character varying(64), content text NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (comment_id) )
CREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, follower_user_id character varying(64) NOT NULL, following_user_id character varying(64) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) )
CREATE TABLE social_media.hashtags ( hashtag_id character varying(64) NOT NULL, tag_name character varying(100) NOT NULL UNIQUE, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (hashtag_id) )
CREATE TABLE social_media.post_hashtags ( post_hashtag_id character varying(64) NOT NULL, post_id character varying(64) NOT NULL, hashtag_id character varying(64) NOT NULL, PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) )
CREATE TABLE social_media.messages ( message_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, sender_user_id character varying(64) NOT NULL, content text, media_url text, media_type character varying(20), sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (message_id) )
CREATE TABLE social_media.conversation_participants ( participant_id character varying(64) NOT NULL, conversation_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, last_read_at timestamp, PRIMARY KEY (participant_id), CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) )
CREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, recipient_user_id character varying(64) NOT NULL, sender_user_id character varying(64), notification_type character varying(30) NOT NULL, target_entity_id character varying(64), target_entity_type character varying(20), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, read_at timestamp, PRIMARY KEY (notification_id) )
CREATE TABLE social_media.user_settings ( setting_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL UNIQUE, theme character varying(20) DEFAULT 'light', email_notifications_enabled boolean DEFAULT true, push_notifications_enabled boolean DEFAULT true, private_profile boolean DEFAULT false, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (setting_id) )
| [
{
"role": "user",
"content": "List all users who commented on posts tagged with hashtag 'spring', showing user_id, comment_id, content, and tag_name.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.user_id, c.comment_id, c.content, h.tag_name\nFROM social_media.comments c\nJOIN ... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, medication_name character varying(255) NOT NULL, generic_name character varying(255), manufacturer character varying(100), ndc_code character varying(20) UNIQUE, description text, PRIMARY KEY (medication_id) )
| [
{
"role": "user",
"content": "Show me all medications, their manufacturer, and NDC code for medications manufactured by 'Johnson & Johnson' or 'Roche'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT medication_name, manufacturer, ndc_code FROM healthcare.medications WHERE manufac... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE legal_services.documents (
document_id character varying(64) NOT NULL, -- unique identifier for the document
case_id character varying(64) NOT NULL, -- FK to cases table
document_name character varying(255) NOT NULL, -- name of the document file
document_type character varying(100), -- e.g., Pleading, Contract, Evidence, Correspondence
storage_path text NOT NULL, -- path or reference to the document storage location
uploaded_by_lawyer_id character varying(64), -- FK to lawyers table (who uploaded it)
upload_timestamp timestamp NOT NULL, -- time the document was uploaded
version integer DEFAULT 1, -- document version number
description text, -- brief description or notes about the document
PRIMARY KEY (document_id)
)
| [
{
"role": "user",
"content": "Find pairs of documents in the same case where one document is version 1 and the other is the highest version for that document_name, showing case_id, document_name, version1, latest_version, version1_upload_timestamp, and latest_upload_timestamp.",
"sql": null
},
{
... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE legal_services.cases (
case_id character varying(64) NOT NULL, -- unique identifier for the case/matter
case_number character varying(100) UNIQUE, -- official case number (court or internal)
case_name text NOT NULL, -- descriptive name or title for the case
client_id character varying(64) NOT NULL, -- FK to clients table
lead_lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (primary lawyer responsible)
case_type character varying(100) NOT NULL, -- e.g., Litigation, Corporate, Family Law, IP
status character varying(50) NOT NULL, -- e.g., Open, Closed, Pending, On Hold, Appealed
date_opened timestamp NOT NULL, -- date the case was formally opened
date_closed timestamp, -- date the case was closed (nullable)
description text, -- detailed description of the case
court_jurisdiction character varying(128), -- court or jurisdiction if applicable
PRIMARY KEY (case_id)
)
CREATE TABLE legal_services.time_entries ( entry_id text PRIMARY KEY, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable bool, is_billed bool, invoice_id text, created_at timestamp )
CREATE TABLE legal_services.appointments ( appointment_id.text, client_id.text, lawyer_id.text, case_id.text, start_time.timestamp, end_time.timestamp, location.text, subject.text, notes.text, status.text, created_at.timestamp )
| [
{
"role": "user",
"content": "Show me the total hours spent by each lawyer for each case, along with the case number and lawyer ID.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT t.case_id, c.case_number, t.lawyer_id, SUM(t.hours_spent) AS total_hours\nFROM legal_services.time_en... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.transactions (
transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction
block_id character varying(64) NOT NULL, -- identifier of the block containing the transaction
sender_address character varying(128) NOT NULL, -- address of the sender
receiver_address character varying(128) NOT NULL, -- address of the receiver
amount numeric(38,14) NOT NULL, -- amount transferred
timestamp timestamp NOT NULL, -- time when the transaction was created
signature text NOT NULL, -- digital signature of the transaction
PRIMARY KEY (transaction_id)
)
| [
{
"role": "user",
"content": "Find all pairs of transactions where the sender address and the receiver address are the same, but the transactions occurred on different days. Show transaction IDs, addresses, and their timestamps.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT t1.t... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
"CREATE TABLE cex_token_balance (",
"snapshot_time character varying(32) NOT NULL, -- the snapshot time of record, converted from original timestamp",
"chain character varying(128) NOT NULL, -- the chain that the token resides",
"address character varying(128) NOT NULL, -- the address that holds the assets, owned by a CEX",
"exchange character varying(512) NOT NULL, -- a centralized exchange name",
"token_address character varying(128) NOT NULL, -- token contract address",
"token_symbol character varying(512), --token symbol",
"balance numeric(38,10), -- token balance",
"usd_value numeric(38,14), -- value of the token held in USD",
"price double precision, --price of the token in USD",
",PRIMARY KEY (snapshot_time, exchange, address, chain, token_address));"
| [
{
"role": "user",
"content": "Which token symbol has the highest price among all tokens held by CEXes on the Polygon chain?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT token_symbol, MAX(price) AS max_price FROM cex_token_balance WHERE chain = 'Polygon' GROUP BY token_symbol OR... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE hospitality_technology.reviews ( review_id.text, property_id.text, reservation_id.text, guest_id.text, rating_overall.integer, rating_cleanliness.integer, rating_service.integer, rating_location.integer, rating_value.integer, comment.text, review_source.text, review_date.timestamp, is_public.boolean, staff_response.text, response_staff_id.text, response_date.timestamp )
| [
{
"role": "user",
"content": "Show me reviews from 'Expedia' that have an overall rating of 1 or 2.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT review_id, property_id, guest_id, rating_overall, review_date, comment FROM hospitality_technology.reviews WHERE review_source = 'Exp... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE token_basic_info ( coin_id text, token_name text, token_symbol text, token_address text, chain text, price numeric, price_change_percentage_1h numeric, price_change_percentage_24h numeric, price_change_percentage_7d numeric, highest_price_24h numeric, lowest_price_24h numeric, market_cap numeric, market_cap_rank numeric, market_cap_change_percentage_24h text, total_volume text, narrative text, trend_rank numeric )
CREATE TABLE narrative_info ( narrative text, top_3_coins text, price_change_percentage_1h numeric, price_change_percentage_24h numeric, price_change_percentage_7d numeric, market_cap numeric, volume_24h numeric, trend_rank numeric, token_num numeric )
CREATE TABLE cex_token_balance ( snapshot_time text, chain text, address text, exchange text, token_address text, token_symbol text, balance numeric, usd_value numeric, price numeric )
CREATE TABLE smart_money_profit ( address text, rank numeric, profit numeric, roi numeric, realized_ratio numeric, most_profit_token text, last_trade_time text, chain text )
CREATE TABLE smart_money_token_inflow ( token_address text, token_symbol text, token_amount numeric, usd_value numeric, avg_price numeric, type numeric, address_amount numeric, narrative text, chain text )
| [
{
"role": "user",
"content": "Which exchange holds the largest total USD value of the token with the highest 24h price increase in the 'AI' narrative, and what is that value?",
"sql": null
},
{
"role": "assistant",
"content": "SELECT ctb.exchange, SUM(ctb.usd_value) AS total_usd_value\nFROM ... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE legal_services.clients ( client_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, company_name character varying(200), email character varying(128) UNIQUE NOT NULL, phone character varying(32), address text, date_registered timestamp NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (client_id) )
CREATE TABLE legal_services.law_firms ( firm_id character varying(64) NOT NULL, firm_name character varying(200) NOT NULL, address text NOT NULL, phone character varying(32), website character varying(255), founded_date date, managing_partner_id character varying(64), PRIMARY KEY (firm_id) )
CREATE TABLE legal_services.cases ( case_id character varying(64) NOT NULL, case_number character varying(100) UNIQUE, case_name text NOT NULL, client_id character varying(64) NOT NULL, lead_lawyer_id character varying(64) NOT NULL, case_type character varying(100) NOT NULL, status character varying(50) NOT NULL, date_opened timestamp NOT NULL, date_closed timestamp, description text, court_jurisdiction character varying(128), PRIMARY KEY (case_id) )
CREATE TABLE legal_services.documents ( document_id character varying(64) NOT NULL, case_id character varying(64) NOT NULL, document_name character varying(255) NOT NULL, document_type character varying(100), storage_path text NOT NULL, uploaded_by_lawyer_id character varying(64), upload_timestamp timestamp NOT NULL, version integer DEFAULT 1, description text, PRIMARY KEY (document_id) )
CREATE TABLE legal_services.appointments ( appointment_id character varying(64) NOT NULL, client_id character varying(64) NOT NULL, lawyer_id character varying(64) NOT NULL, case_id character varying(64), start_time timestamp NOT NULL, end_time timestamp NOT NULL, location text, subject character varying(255), notes text, status character varying(50) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (appointment_id) )
| [
{
"role": "user",
"content": "Show me all cases opened in the year 2024, along with the full name of the client for each case.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT T1.case_number, T1.case_name, T2.first_name, T2.last_name FROM cases AS T1 JOIN clients AS T2 ON T1.client... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE hospitality_technology.properties ( property_id text, property_name text, address_line1 text, address_line2 text, city text, state_province text, postal_code text, country_code text, phone_number text, email_address text, property_type text, star_rating numeric, timezone text, manager_staff_id text, created_at timestamp, updated_at timestamp )
CREATE TABLE hospitality_technology.rooms ( room_id text, property_id text, room_number text, room_type_id text, floor integer, status text, is_smoking boolean, features text, current_condition text, last_cleaned_at timestamp )
CREATE TABLE hospitality_technology.room_types ( room_type_id text, property_id text, type_name text, description text, base_rate numeric, max_occupancy integer, bed_type text, area_sqft numeric, amenities text )
CREATE TABLE hospitality_technology.guests ( guest_id text, first_name text, last_name text, email text, phone_number text, date_of_birth date, address_line1 text, city text, state_province text, postal_code text, country_code text, preferences text, loyalty_member_id text, communication_consent boolean, created_at timestamp, updated_at timestamp )
CREATE TABLE hospitality_technology.reservations ( reservation_id text, property_id text, guest_id text, room_id text, room_type_id text, check_in_date date, check_out_date date, actual_check_in_ts timestamp, actual_check_out_ts timestamp, num_adults integer, num_children integer, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )
CREATE TABLE hospitality_technology.staff ( staff_id text, property_id text, first_name text, last_name text, position text, work_email text, work_phone text, hire_date date, termination_date date, is_active boolean, access_level integer, manager_id text, created_at timestamp )
CREATE TABLE hospitality_technology.services ( service_id text, property_id text, service_name text, description text, category text, price numeric, unit text, is_available boolean, department text )
CREATE TABLE hospitality_technology.service_orders ( order_id text, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity integer, unit_price numeric, total_price numeric, status text, notes text, bill_id text )
CREATE TABLE hospitality_technology.reviews ( review_id text, property_id text, reservation_id text, guest_id text, rating_overall integer, rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp )
| [
{
"role": "user",
"content": "Show me all service orders for spa services in the last month, including the guest name and staff who delivered the service.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT so.order_id, g.first_name, g.last_name, s.service_name, st.first_name AS staff... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE legal_services.appointments ( appointment_id character varying(64) NOT NULL, client_id character varying(64) NOT NULL, lawyer_id character varying(64) NOT NULL, case_id character varying(64), start_time timestamp NOT NULL, end_time timestamp NOT NULL, location text, subject character varying(255), notes text, status character varying(50) NOT NULL, created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (appointment_id) )
| [
{
"role": "user",
"content": "Show me the appointment ID, start time, and subject for all appointments scheduled with lawyer 'lawyer123'.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT appointment_id, start_time, subject FROM legal_services.appointments WHERE lawyer_id = 'lawyer1... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE social_media.comments ( comment_id text PRIMARY KEY, post_id text, user_id text, parent_comment_id text, content text, created_at timestamp, updated_at timestamp )
| [
{
"role": "user",
"content": "Show me all replies to comments, including the reply's comment ID, the parent comment ID, and the content.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT comment_id, parent_comment_id, content FROM social_media.comments WHERE parent_comment_id IS NOT... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government_services.citizens (
citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen
national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number
first_name character varying(100) NOT NULL,
last_name character varying(100) NOT NULL,
date_of_birth date NOT NULL,
gender character varying(20),
primary_address text NOT NULL, -- full primary residential address
contact_email character varying(128) UNIQUE,
contact_phone character varying(32),
registration_date timestamp NOT NULL, -- when the citizen profile was created
is_verified boolean DEFAULT false, -- whether identity has been officially verified
PRIMARY KEY (citizen_id)
)
CREATE TABLE government_services.agencies ( agency_id text, agency_name text, jurisdiction_level text, primary_contact_email text, main_phone_number text, website_url text, established_date date, parent_agency_id text )
CREATE TABLE government_services.applications ( application_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, service_id character varying(64) NOT NULL, submitted_at timestamp NOT NULL, status character varying(50) NOT NULL, last_updated_at timestamp NOT NULL, assigned_employee_id character varying(64), decision_date date, notes text, reference_number character varying(100) UNIQUE, PRIMARY KEY (application_id) )
CREATE TABLE government_services.documents ( document_id text, application_id text, citizen_id text, document_type text, file_reference text, upload_timestamp timestamp, expiry_date date, verification_status text, verified_by_employee_id text, verification_timestamp timestamp )
CREATE TABLE government_services.payments ( payment_id text, application_id text, citizen_id text, service_id text, amount numeric, currency text, payment_method text, payment_provider_reference text, payment_timestamp timestamp, status text, notes text )
CREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, job_title character varying(150) NOT NULL, department character varying(100), work_email character varying(128) NOT NULL UNIQUE, work_phone character varying(32), hire_date date NOT NULL, termination_date date, access_level character varying(50), manager_employee_id character varying(64), PRIMARY KEY (employee_id) )
CREATE TABLE government_services.service_locations (
location_id character varying(64) NOT NULL, -- unique identifier for the physical location
agency_id character varying(64) NOT NULL, -- FK to agencies table
location_name character varying(200), -- e.g., Downtown DMV Office
address text NOT NULL,
city character varying(100),
state character varying(50),
postal_code character varying(20),
latitude numeric(9, 6),
longitude numeric(9, 6),
operating_hours text, -- description of opening times
contact_phone character varying(32),
is_accessible boolean, -- accessibility information (e.g., wheelchair access)
PRIMARY KEY (location_id)
)
CREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, citizen_id character varying(64) NOT NULL, application_id character varying(64), message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, sent_at timestamp NOT NULL, status character varying(30) NOT NULL, related_entity_type character varying(50), related_entity_id character varying(64), PRIMARY KEY (notification_id) )
| [
{
"role": "user",
"content": "Which citizens have made the highest total payments in USD? Show their full name and total payment amount, ordered by total in descending order, limited to the top 3.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT c.first_name || ' ' || c.last_name A... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE financial_services.loans (
loan_id character varying(64) NOT NULL, -- unique identifier for the loan, could be same as account_id
account_id character varying(64) NOT NULL UNIQUE, -- link to the general account record
loan_type character varying(50) NOT NULL, -- e.g., Mortgage, Personal, Auto, Student
principal_amount numeric(19, 4) NOT NULL, -- original loan amount
current_principal_balance numeric(19, 4) NOT NULL, -- remaining principal
interest_rate numeric(6, 4) NOT NULL, -- annual interest rate
term_months integer NOT NULL, -- loan term in months
origination_date date NOT NULL, -- date the loan was disbursed
maturity_date date NOT NULL, -- date the loan is due to be fully repaid
monthly_payment numeric(12, 4), -- scheduled monthly payment amount
collateral_description text, -- description of collateral, if secured loan
status character varying(32) NOT NULL, -- e.g., Active, Paid Off, Defaulted
PRIMARY KEY (loan_id),
FOREIGN KEY (account_id) REFERENCES financial_services.accounts(account_id)
)
| [
{
"role": "user",
"content": "Retrieve all pairs of loans for the same account where both loans are active and have different loan types. Show account_id, loan_id as loan_a, loan_type as type_a, loan_id as loan_b, and loan_type as type_b.",
"sql": null
},
{
"role": "assistant",
"content": "S... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )
CREATE TABLE healthcare.appointments ( appointment_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, appointment_time timestamp with time zone NOT NULL, duration_minutes integer NOT NULL, reason text, status character varying(32) NOT NULL, location_id character varying(64), notes text, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (appointment_id) )
CREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )
CREATE TABLE healthcare.prescriptions ( prescription_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, medication_id character varying(64) NOT NULL, dosage character varying(100) NOT NULL, frequency character varying(100) NOT NULL, route character varying(50), start_date date NOT NULL, end_date date, quantity_dispensed numeric(10,2), refills_allowed integer NOT NULL DEFAULT 0, prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) )
| [
{
"role": "user",
"content": "Show all prescriptions with prescription_id, patient_id, medication_id, quantity_dispensed, and refills_allowed.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT prescription_id, patient_id, medication_id, quantity_dispensed, refills_allowed FROM healt... |
You are an expert in writing database language and you can refuse the user's question if the question is not related to the table structure. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE manufacturing.employees ( employee_id text PRIMARY KEY, first_name text, last_name text, job_title text, skill_certifications text, hire_date date, assigned_line_id text, employment_status text, supervisor_employee_id text )
| [
{
"role": "user",
"content": "What is the total number of vacation days taken by employee with ID 'EMP101' in the past year?",
"sql": null
},
{
"role": "assistant",
"content": "I'm sorry, but I can't provide information on the vacation days taken by an employee as this data is not stored in ... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE transportation.drivers ( driver_id character varying(64) NOT NULL, employee_id character varying(64) NOT NULL UNIQUE, first_name character varying(128) NOT NULL, last_name character varying(128) NOT NULL, license_number character varying(64) NOT NULL UNIQUE, license_expiry_date date NOT NULL, contact_number character varying(32), email character varying(128) UNIQUE, hire_date date NOT NULL, status character varying(32) NOT NULL, PRIMARY KEY (driver_id) )
CREATE TABLE transportation.locations ( location_id character varying(64) NOT NULL, name character varying(255) NOT NULL, type character varying(64) NOT NULL, address_line1 character varying(255), city character varying(128), state_province character varying(128), postal_code character varying(32), country character varying(64) NOT NULL, latitude numeric(9, 6), longitude numeric(9, 6), timezone character varying(64), PRIMARY KEY (location_id) )
CREATE TABLE transportation.fuel_logs ( fuel_log_id character varying(64) NOT NULL, vehicle_id character varying(64) NOT NULL, trip_id character varying(64), log_timestamp timestamp with time zone NOT NULL, fuel_type character varying(32) NOT NULL, quantity numeric(10, 3) NOT NULL, unit character varying(16) NOT NULL, cost_per_unit numeric(8, 4), total_cost numeric(10, 2) NOT NULL, odometer_reading integer, location_id character varying(64), PRIMARY KEY (fuel_log_id) )
CREATE TABLE transportation.passengers ( passenger_id character varying(64) NOT NULL, first_name character varying(128) NOT NULL, last_name character varying(128) NOT NULL, email character varying(128) UNIQUE, phone_number character varying(32) UNIQUE, date_of_birth date, loyalty_program_id character varying(64), created_at timestamp with time zone NOT NULL, PRIMARY KEY (passenger_id) )
CREATE TABLE transportation.bookings ( booking_id character varying(64) NOT NULL, passenger_id character varying(64) NOT NULL, trip_id character varying(64) NOT NULL, seat_number character varying(16), booking_time timestamp with time zone NOT NULL, status character varying(32) NOT NULL, fare numeric(10, 2) NOT NULL, payment_transaction_id character varying(128), special_requests text, PRIMARY KEY (booking_id) )
| [
{
"role": "user",
"content": "List the names and cities of all locations that have at least one fuel log entry recorded.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT DISTINCT l.name, l.city\nFROM transportation.locations l\nJOIN transportation.fuel_logs f ON l.location_id = f.l... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE government_services.citizens (
citizen_id character varying(64) NOT NULL, -- unique identifier for the citizen
national_id_number character varying(128) NOT NULL UNIQUE, -- official national identification number
first_name character varying(100) NOT NULL,
last_name character varying(100) NOT NULL,
date_of_birth date NOT NULL,
gender character varying(20),
primary_address text NOT NULL, -- full primary residential address
contact_email character varying(128) UNIQUE,
contact_phone character varying(32),
registration_date timestamp NOT NULL, -- when the citizen profile was created
is_verified boolean DEFAULT false, -- whether identity has been officially verified
PRIMARY KEY (citizen_id)
)
| [
{
"role": "user",
"content": "Show the count of citizens grouped by their verification status.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT is_verified, COUNT(*) FROM government_services.citizens GROUP BY is_verified;",
"sql": null
},
{
"role": "user",
"content"... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE insurance.agents ( agent_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, agency_name character varying(150), license_number character varying(100) NOT NULL UNIQUE, license_state character varying(50) NOT NULL, contact_email character varying(128) UNIQUE, contact_phone character varying(30), hire_date date, termination_date date, status character varying(20) NOT NULL DEFAULT 'Active', commission_rate numeric(5, 4) NOT NULL DEFAULT 0.05, manager_id character varying(64), PRIMARY KEY (agent_id) )
| [
{
"role": "user",
"content": "Show all active agents along with their respective managers' full names.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT a.agent_id, a.first_name || ' ' || a.last_name AS agent_name, m.first_name || ' ' || m.last_name AS manager_name FROM insurance.ag... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE blockchain.blocks ( block_id text, previous_block_id text, timestamp timestamp, nonce integer, merkle_root text, difficulty integer )
CREATE TABLE blockchain.transactions ( transaction_id text, block_id text, sender_address text, receiver_address text, amount numeric, timestamp timestamp, signature text )
CREATE TABLE blockchain.addresses ( address_id text, public_key text, balance numeric )
CREATE TABLE blockchain.wallets ( wallet_id text, user_id text, address_id text, private_key text )
| [
{
"role": "user",
"content": "List the block_id, timestamp, and the total amount of transactions for each block, along with the sender and receiver addresses for each transaction that occurred on April 10th, 2023.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT b.block_id, b.times... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.diagnoses (
diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry
record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry
patient_id character varying(64) NOT NULL, -- FK to patients table
doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)
diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)
code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used
description text, -- textual description of the diagnosis
diagnosis_date date NOT NULL, -- date the diagnosis was made
status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out
is_chronic boolean DEFAULT false, -- flag for chronic conditions
PRIMARY KEY (diagnosis_id)
)
| [
{
"role": "user",
"content": "I need to find all pairs of diagnoses for the same patient where one diagnosis is chronic and the other is non-chronic. Show patient_id, chronic diagnosis_id as chronic_id, non-chronic diagnosis_id as acute_id, chronic diagnosis_date, and acute diagnosis_date.",
"sql": null... |
You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement.
##Table Structure
CREATE TABLE healthcare.patients (
patient_id character varying(64) NOT NULL, -- unique identifier for the patient
first_name character varying(100) NOT NULL, -- patient's first name
last_name character varying(100) NOT NULL, -- patient's last name
date_of_birth date NOT NULL, -- patient's date of birth
gender character varying(10), -- patient's gender (e.g., Male, Female, Other)
address text, -- patient's home address
phone_number character varying(20), -- patient's phone number
email character varying(128) UNIQUE, -- patient's email address
emergency_contact_name character varying(200), -- name of emergency contact
emergency_contact_phone character varying(20), -- phone number of emergency contact
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record creation time
updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, -- record last update time
PRIMARY KEY (patient_id)
)
CREATE TABLE healthcare.doctors (
doctor_id character varying(64) NOT NULL, -- unique identifier for the doctor
first_name character varying(100) NOT NULL, -- doctor's first name
last_name character varying(100) NOT NULL, -- doctor's last name
specialty character varying(100) NOT NULL, -- doctor's medical specialty
license_number character varying(50) UNIQUE NOT NULL, -- doctor's medical license number
phone_number character varying(20), -- doctor's contact phone
email character varying(128) UNIQUE, -- doctor's contact email
hospital_affiliation_id character varying(64), -- FK to hospitals table (optional)
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (doctor_id)
)
CREATE TABLE healthcare.appointments (
appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment
patient_id character varying(64) NOT NULL, -- FK to patients table
doctor_id character varying(64) NOT NULL, -- FK to doctors table
appointment_time timestamp with time zone NOT NULL, -- date and time of the appointment
duration_minutes integer NOT NULL, -- expected duration in minutes
reason text, -- reason for the visit
status character varying(32) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-show
location_id character varying(64), -- FK to a potential locations/clinics table
notes text, -- notes related to scheduling
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (appointment_id)
)
CREATE TABLE healthcare.medical_records (
record_id character varying(64) NOT NULL, -- unique identifier for the medical record entry
patient_id character varying(64) NOT NULL, -- FK to patients table
appointment_id character varying(64) UNIQUE, -- FK to appointments table (can be null if record not tied to specific appt)
doctor_id character varying(64) NOT NULL, -- FK to doctors table (doctor creating the record)
record_date timestamp with time zone NOT NULL, -- date the record/observation was made
chief_complaint text, -- patient's primary reason for visit
present_illness_history text, -- detailed history of the current issue
past_medical_history text, -- relevant past conditions/surgeries
physical_examination_notes text, -- findings from the physical exam
assessment text, -- doctor's assessment/diagnosis summary
treatment_plan text, -- planned course of action
vitals jsonb, -- store vitals like BP, HR, Temp as structured JSON
created_at timestamp with time zone NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (record_id)
)
CREATE TABLE healthcare.diagnoses (
diagnosis_id character varying(64) NOT NULL, -- unique identifier for the diagnosis entry
record_id character varying(64) NOT NULL, -- FK linking to the specific medical record entry
patient_id character varying(64) NOT NULL, -- FK to patients table
doctor_id character varying(64) NOT NULL, -- FK to doctors table (diagnosing doctor)
diagnosis_code character varying(20) NOT NULL, -- standard code (e.g., ICD-10)
code_type character varying(10) NOT NULL DEFAULT 'ICD-10', -- type of code used
description text, -- textual description of the diagnosis
diagnosis_date date NOT NULL, -- date the diagnosis was made
status character varying(32) NOT NULL, -- e.g., Active, Resolved, Ruled Out
is_chronic boolean DEFAULT false, -- flag for chronic conditions
PRIMARY KEY (diagnosis_id)
)
CREATE TABLE healthcare.patient_insurance (
patient_insurance_id character varying(64) NOT NULL, -- unique identifier for this patient-plan link
patient_id character varying(64) NOT NULL, -- FK to patients table
plan_id character varying(64) NOT NULL, -- FK to insurance_plans table
policy_number character varying(100) NOT NULL, -- patient's policy number
group_number character varying(100), -- group number, if applicable
subscriber_name character varying(200), -- name of the primary policy holder
effective_date date NOT NULL, -- date the coverage begins
expiration_date date, -- date the coverage ends (if known)
is_primary boolean NOT NULL DEFAULT true, -- indicates if this is the primary insurance
PRIMARY KEY (patient_insurance_id),
UNIQUE (patient_id, plan_id, policy_number) -- ensure a patient doesn't have the same policy twice
)
| [
{
"role": "user",
"content": "Show me all patients who have had at least one appointment with a doctor specializing in 'Cardiology'. Include the patient's full name, appointment time, and doctor's full name.",
"sql": null
},
{
"role": "assistant",
"content": "SELECT p.patient_id, p.first_nam... |
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 4