Dataset Viewer
Auto-converted to Parquet Duplicate
system
stringlengths
3.67k
8.63k
conversations
listlengths
4
26
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 trading_platform.wallets ( wallet_id character varying(64) NOT NULL, -- unique identifier for the wallet user_id character varying(64) NOT NULL, -- identifier of the user owning the wallet address character varying(128) NOT NULL, -- address of the wallet private_key text NOT NULL, -- private key of the wallet created_at timestamp NOT NULL, -- time when the wallet was created PRIMARY KEY (wallet_id) ) CREATE TABLE trading_platform.orders ( order_id character varying(64) NOT NULL, -- unique identifier for the order user_id character varying(64) NOT NULL, -- identifier of the user placing the order wallet_id character varying(64) NOT NULL, -- identifier of the wallet used for the order asset_id character varying(64) NOT NULL, -- identifier of the asset being traded order_type character varying(32) NOT NULL, -- type of the order (e.g., buy, sell) quantity numeric(38,14) NOT NULL, -- quantity of the asset in the order price numeric(38,14) NOT NULL, -- price per unit of the asset status character varying(32) NOT NULL, -- status of the order (e.g., open, filled, canceled) created_at timestamp NOT NULL, -- time when the order was created PRIMARY KEY (order_id) ) CREATE TABLE trading_platform.assets ( asset_id character varying(64) NOT NULL, -- unique identifier for the asset name character varying(128) NOT NULL, -- name of the asset symbol character varying(32) NOT NULL, -- symbol of the asset type character varying(32) NOT NULL, -- type of the asset (e.g., cryptocurrency, stock) PRIMARY KEY (asset_id) ) CREATE TABLE trading_platform.utxos ( utxo_id character varying(64) NOT NULL, -- unique identifier for the UTXO transaction_id character varying(64) NOT NULL, -- identifier of the transaction that created the UTXO output_index integer NOT NULL, -- index of the output in the transaction address character varying(128) NOT NULL, -- address that can spend the UTXO amount numeric(38,14) NOT NULL, -- amount of the asset in the UTXO spent boolean NOT NULL, -- whether the UTXO has been spent PRIMARY KEY (utxo_id) ) CREATE TABLE trading_platform.dapps ( dapp_id character varying(64) NOT NULL, -- unique identifier for the DApp name character varying(128) NOT NULL, -- name of the DApp description text NOT NULL, -- description of the DApp url character varying(256) NOT NULL, -- URL of the DApp PRIMARY KEY (dapp_id) ) CREATE TABLE trading_platform.peers ( peer_id character varying(64) NOT NULL, -- unique identifier for the peer ip_address character varying(15) NOT NULL, -- IP address of the peer port integer NOT NULL, -- port number of the peer last_seen timestamp NOT NULL, -- last time the peer was active PRIMARY KEY (peer_id) ) CREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, -- unique identifier for the metadata asset_id character varying(64) NOT NULL, -- identifier of the asset the metadata is associated with key character varying(128) NOT NULL, -- key of the metadata value text NOT NULL, -- value of the metadata PRIMARY KEY (metadata_id) ) CREATE TABLE trading_platform.kyc_audit ( kyc_audit_id character varying(64) NOT NULL, -- unique identifier for the KYC audit user_id character varying(64) NOT NULL, -- identifier of the user being audited status character varying(32) NOT NULL, -- status of the KYC audit (e.g., pending, approved, rejected) reviewed_at timestamp NOT NULL, -- time when the KYC audit was reviewed PRIMARY KEY (kyc_audit_id) ) CREATE TABLE trading_platform.notifications ( notification_id character varying(64) NOT NULL, -- unique identifier for the notification user_id character varying(64) NOT NULL, -- identifier of the user receiving the notification message text NOT NULL, -- message of the notification sent_at timestamp NOT NULL, -- time when the notification was sent read_at timestamp, -- time when the notification was read PRIMARY KEY (notification_id) ) ##Table Structure CREATE TABLE healthcare.doctors ( doctor_id text, first_name text, last_name text, specialty text, license_number text, phone_number text, email text, hospital_affiliation_id text, created_at timestamp, updated_at timestamp ) 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.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text ) ##Table Structure CREATE TABLE gaming_technology.achievements ( achievement_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for an achievement definition game_id uuid NOT NULL, -- FK linking to the game the achievement belongs to name character varying(150) NOT NULL, -- name of the achievement description text NOT NULL, -- how to unlock the achievement icon_url character varying(255), -- URL for the achievement's icon points integer DEFAULT 0, -- points awarded for unlocking (optional) hidden boolean DEFAULT false, -- whether the achievement details are hidden until unlocked PRIMARY KEY (achievement_id) -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id) ) ##Table Structure CREATE TABLE web3.transactions ( transaction_id text, from_address text, to_address text, value numeric, gas_used integer, gas_price numeric, block_number integer, timestamp timestamp, input_data text, status text, nonce integer )
[ { "role": "user", "content": "List each asset's name and symbol along with the total number of open orders for that asset." }, { "role": "assistant", "content": "SELECT a.name,\n a.symbol,\n COUNT(o.order_id) AS open_order_count\nFROM trading_platform.assets a\nLEFT JOIN trading_plat...
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 text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp ) CREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp ) CREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp ) CREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean ) CREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text ) CREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp ) CREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text ) CREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean ) ##Table Structure CREATE TABLE hospitality_technology.reservations ( reservation_id character varying(64) NOT NULL, -- unique identifier for the booking property_id character varying(64) NOT NULL, -- FK to properties table guest_id character varying(64) NOT NULL, -- FK to guests table (primary guest) room_id character varying(64), -- FK to rooms table (assigned room, might be null initially) room_type_id character varying(64) NOT NULL, -- FK to room_types table (booked room type) check_in_date date NOT NULL, -- scheduled check-in date check_out_date date NOT NULL, -- scheduled check-out date actual_check_in_ts timestamp with time zone, -- actual check-in time actual_check_out_ts timestamp with time zone, -- actual check-out time num_adults integer NOT NULL, -- number of adults num_children integer DEFAULT 0, -- number of children status character varying(50) NOT NULL, -- e.g., Pending, Confirmed, CheckedIn, CheckedOut, Cancelled, NoShow booking_source character varying(100), -- e.g., Website, OTA (Expedia, Booking.com), Phone, WalkIn rate_plan_id character varying(64), -- FK to rate_plans table (optional) total_amount numeric(12, 2), -- estimated or final total cost amount_paid numeric(12, 2) DEFAULT 0.00, -- amount already paid special_requests text, -- specific guest requests for this booking created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (reservation_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (room_id) REFERENCES hospitality_technology.rooms(room_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) ) CREATE TABLE hospitality_technology.payments ( payment_id character varying(64) NOT NULL, -- unique identifier for the payment transaction reservation_id character varying(64), -- FK to reservations (if payment is for a stay) guest_id character varying(64) NOT NULL, -- FK to guests (who paid) bill_id character varying(64), -- FK to bills/invoices this payment applies to amount numeric(12,2) NOT NULL, -- amount of the payment currency_code character varying(3) NOT NULL, -- ISO currency code (e.g., USD, EUR) payment_method character varying(50) NOT NULL, -- e.g., CreditCard, Cash, BankTransfer, Points, Voucher card_type character varying(50), -- e.g., Visa, MasterCard, Amex (if CC) card_last_four character varying(4), -- last 4 digits of CC (if CC) transaction_ref character varying(128), -- reference ID from payment gateway or processor payment_timestamp timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the payment occurred status character varying(50) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded, Disputed staff_id_processed character varying(64), -- FK to staff (who processed the payment) notes text, -- notes about the payment PRIMARY KEY (payment_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (staff_id_processed) REFERENCES hospitality_technology.staff(staff_id) ) CREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, -- unique identifier for the review property_id character varying(64) NOT NULL, -- FK to properties table reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good) guest_id character varying(64) NOT NULL, -- FK to guests table rating_overall integer, -- overall score (e.g., 1-5 or 1-10) rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, -- guest's written feedback review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted is_public boolean DEFAULT true, -- whether the review is publicly visible staff_response text, -- official response from the property response_staff_id character varying(64), -- FK to staff (who responded) response_date timestamp with time zone, -- when the response was posted PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) ) ##Table Structure 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 )
[ { "role": "user", "content": "List patient_id, full name, policy_number, plan_type, and insurance_provider for all active primary insurance policies." }, { "role": "assistant", "content": "SELECT pi.patient_id,\n p.first_name,\n p.last_name,\n pi.policy_number,\n ip.plan_...
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.passengers ( passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger first_name character varying(128) NOT NULL, -- passenger's first name last_name character varying(128) NOT NULL, -- passenger's last name email character varying(128) UNIQUE, -- email address phone_number character varying(32) UNIQUE, -- phone number date_of_birth date, -- passenger's date of birth loyalty_program_id character varying(64), -- identifier for loyalty program membership created_at timestamp with time zone NOT NULL, -- time when the passenger record was created PRIMARY KEY (passenger_id) ) ##Table Structure CREATE TABLE government_services.citizens ( citizen_id.text, national_id_number.text, first_name.text, last_name.text, date_of_birth.date, gender.text, primary_address.text, contact_email.text, contact_phone.text, registration_date.timestamp, is_verified.boolean ) 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.text, citizen_id.text, service_id.text, submitted_at.timestamp, status.text, last_updated_at.timestamp, assigned_employee_id.text, decision_date.date, notes.text, reference_number.text ) 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.text, agency_id.text, first_name.text, last_name.text, job_title.text, department.text, work_email.text, work_phone.text, hire_date.date, termination_date.date, access_level.text, manager_employee_id.text ) CREATE TABLE government_services.service_locations ( location_id.text, agency_id.text, location_name.text, address.text, city.text, state.text, postal_code.text, latitude.numeric, longitude.numeric, operating_hours.text, contact_phone.text, is_accessible.boolean ) CREATE TABLE government_services.notifications ( notification_id.text, citizen_id.text, application_id.text, message_subject.text, message_body.text, channel.text, sent_at.timestamp, status.text, related_entity_type.text, related_entity_id.text ) ##Table Structure 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.services ( service_id.text, agency_id.text, service_name.text, description.text, category.text, eligibility_criteria.text, standard_fee.numeric, average_processing_time_days.integer, is_active.boolean, online_application_url.text ) CREATE TABLE government_services.applications ( application_id.text, citizen_id.text, service_id.text, submitted_at.timestamp, status.text, last_updated_at.timestamp, assigned_employee_id.text, decision_date.date, notes.text, reference_number.text ) 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.service_locations ( location_id.text, agency_id.text, location_name.text, address.text, city.text, state.text, postal_code.text, latitude.numeric, longitude.numeric, operating_hours.text, contact_phone.text, is_accessible.boolean ) CREATE TABLE government_services.appointments ( appointment_id.text, citizen_id.text, employee_id.text, location_id.text, service_id.text, scheduled_start_time.timestamp, scheduled_end_time.timestamp, purpose.text, status.text, booking_method.text, created_at.timestamp, notes.text ) CREATE TABLE government_services.notifications ( notification_id.text, citizen_id.text, application_id.text, message_subject.text, message_body.text, channel.text, sent_at.timestamp, status.text, related_entity_type.text, related_entity_id.text ) ##Table Structure CREATE TABLE gaming_technology.players ( player_id.uuid, username.text, email.text, password_hash.text, registration_date.timestamptz, last_login.timestamptz, country_code.text, status.text, profile_data.jsonb ) CREATE TABLE gaming_technology.games ( game_id.uuid, title.text, developer_id.uuid, publisher_id.uuid, genre.text, release_date.date, description.text, platform.text, engine.text, website.text ) CREATE TABLE gaming_technology.developers ( developer_id.uuid, name.text, country.text, founded_year.integer, website.text, created_at.timestamptz ) CREATE TABLE gaming_technology.servers ( server_id.uuid, game_id.uuid, server_name.text, region.text, ip_address.text, port.integer, current_players.integer, max_players.integer, status.text, last_heartbeat.timestamptz ) CREATE TABLE gaming_technology.achievements ( achievement_id.uuid, game_id.uuid, name.text, description.text, icon_url.text, points.integer, hidden.boolean ) CREATE TABLE gaming_technology.player_achievements ( player_achievement_id.uuid, player_id.uuid, achievement_id.uuid, unlocked_at.timestamptz ) CREATE TABLE gaming_technology.in_game_items ( item_id.uuid, game_id.uuid, item_name.text, item_type.text, description.text, rarity.text, cost_currency.text, cost_amount.numeric, attributes.jsonb ) CREATE TABLE gaming_technology.player_inventory ( inventory_id.uuid, player_id.uuid, item_id.uuid, quantity.integer, acquired_at.timestamptz, instance_data.jsonb ) ##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) ) ##Table Structure CREATE TABLE insurance.agents ( agent_id.text, first_name.text, last_name.text, agency_name.text, license_number.text, license_state.text, contact_email.text, contact_phone.text, hire_date.date, termination_date.date, status.text, commission_rate.numeric, manager_id.text )
[ { "role": "user", "content": "Show me the email and full name of passengers who are enrolled in a loyalty program, along with the date they joined, ordered by most recent sign-up." }, { "role": "assistant", "content": "SELECT email, CONCAT(first_name, ' ', last_name) AS full_name, created_at FRO...
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.vehicles ( vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate vin character varying(17) UNIQUE, -- vehicle identification number make character varying(64) NOT NULL, -- manufacturer of the vehicle model character varying(64) NOT NULL, -- model of the vehicle year integer NOT NULL, -- manufacturing year type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van) capacity integer, -- passenger or cargo capacity fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned depot_id character varying(64), -- identifier of the home depot/base acquisition_date date, -- date the vehicle was acquired PRIMARY KEY (vehicle_id) ) 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.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text ) CREATE TABLE transportation.trips ( trip_id character varying(64) NOT NULL, -- unique identifier for a specific trip instance route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips) vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used driver_id character varying(64) NOT NULL, -- identifier of the driver operating scheduled_departure timestamp with time zone NOT NULL, -- planned departure time actual_departure timestamp with time zone, -- actual departure time scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time actual_arrival timestamp with time zone, -- actual arrival time origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin) destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination) status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled passenger_count integer, -- number of passengers (if applicable) cargo_manifest_id character varying(64), -- link to cargo details (if applicable) PRIMARY KEY (trip_id) ) CREATE TABLE transportation.locations ( location_id.text, name.text, type.text, address_line1.text, city.text, state_province.text, postal_code.text, country.text, latitude.numeric, longitude.numeric, timezone.text ) CREATE TABLE transportation.maintenance_logs ( log_id character varying(64) NOT NULL, vehicle_id character varying(64) NOT NULL, service_date date NOT NULL, odometer_reading integer, service_type character varying(128) NOT NULL, description text NOT NULL, cost numeric(10, 2), mechanic_name character varying(128), next_service_due_date date, PRIMARY KEY (log_id) ) CREATE TABLE transportation.fuel_logs ( fuel_log_id text PRIMARY KEY, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading int, location_id text ) CREATE TABLE transportation.passengers ( passenger_id text PRIMARY KEY, first_name text, last_name text, email text, phone_number text, date_of_birth date, loyalty_program_id text, created_at timestamp ) ##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) ) ##Table Structure 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) )
[ { "role": "user", "content": "Show the top 10 most expensive fuel log entries including fuel_log_id, vehicle make and model, location name and city, and total_cost." }, { "role": "assistant", "content": "SELECT f.fuel_log_id,\n v.make,\n v.model,\n loc.name AS location_name,\n ...
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_metas ( block_timestamp timestamp, block_number bigint, transaction_hash text, transaction_index bigint, from_address text, contract_address text, symbol text, total_supply text, name text, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info text, pk integer ) CREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text ) CREATE TABLE nft_holder_historical ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk integer ) CREATE TABLE sui_coins_metadata ( object_id text, coin_type text, status text, decimals bigint, description text, icon_url text, symbol text, name text ) CREATE TABLE nft_metadata ( blockchain text, contract_address text, token_id text, contract_name text, erc_type text, amount bigint, minter text, owner text, mint_block_number bigint, mint_time bigint, mint_transaction_hash text, mint_price text, token_uri text, metadata text, name text, image_uri text, traits text, updated_at bigint, status text, rarity_score real, rarity_rank integer, unique_attribute_count integer, pk integer ) CREATE TABLE nft_collections ( blockchain text, contract_address text, name text, symbol text, deploy_block_number bigint, deploy_block_time bigint, erc_type text, owner text, traits text, description text, slug text, media_info text, image_url text, banner_image_url text, updated_at bigint, banner text, token_count bigint, floor_price text, floor_price_symbol text, floor_price_contract text, pk integer ) CREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp ) CREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text, pk integer ) CREATE TABLE mud_holesky_redstone ( address text, table_id text, key_bytes text, key0 text, key1 text, static_data text, encoded_lengths text, dynamic_data text, is_deleted boolean, block_number bigint, log_index bigint ) CREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply text, amount text ) CREATE TABLE token_info_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text ) CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text ) CREATE TABLE token_activities_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text ) CREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal ) CREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text ) ##Table Structure CREATE TABLE web3.contracts ( contract_id character varying(64) NOT NULL, -- unique identifier for the contract address character varying(128) NOT NULL, -- address of the deployed contract abi text NOT NULL, -- application binary interface of the contract bytecode text NOT NULL, -- bytecode of the contract deployer_address character varying(128) NOT NULL, -- address of the deployer deployed_at timestamp NOT NULL, -- time when the contract was deployed network_id character varying(64) NOT NULL, -- identifier of the network where the contract is deployed status character varying(32) NOT NULL, -- status of the contract (e.g., active, deprecated) PRIMARY KEY (contract_id) ) CREATE TABLE web3.transactions ( transaction_id character varying(64) NOT NULL, -- unique identifier for the transaction from_address character varying(128) NOT NULL, -- address of the sender to_address character varying(128), -- address of the receiver (can be null for contract deployment) value numeric(38,14) NOT NULL, -- value transferred gas_used integer NOT NULL, -- amount of gas used by the transaction gas_price numeric(38,14) NOT NULL, -- price of gas at the time of the transaction block_number integer NOT NULL, -- block number containing the transaction timestamp timestamp NOT NULL, -- time when the transaction was mined input_data text, -- input data of the transaction (can be null) status character varying(32) NOT NULL, -- status of the transaction (e.g., success, failed) nonce integer NOT NULL, -- nonce of the sender at the time of the transaction PRIMARY KEY (transaction_id) ) CREATE TABLE web3.tokens ( token_id character varying(64) NOT NULL, -- unique identifier for the token contract_address character varying(128) NOT NULL, -- address of the token contract token_name character varying(128) NOT NULL, -- name of the token token_symbol character varying(32) NOT NULL, -- symbol of the token decimals integer NOT NULL, -- number of decimals for the token total_supply numeric(38,14) NOT NULL, -- total supply of the token PRIMARY KEY (token_id) ) CREATE TABLE web3.token_transfers ( transfer_id character varying(64) NOT NULL, -- unique identifier for the transfer token_id character varying(64) NOT NULL, -- identifier of the token being transferred from_address character varying(128) NOT NULL, -- address of the sender to_address character varying(128) NOT NULL, -- address of the receiver value numeric(38,14) NOT NULL, -- amount of tokens transferred transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer log_index integer NOT NULL, -- index of the transfer log in the transaction PRIMARY KEY (transfer_id) ) ##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 all SUI coin types with more than 6 decimals and status 'exists' in the metadata table." }, { "role": "assistant", "content": "SELECT coin_type, symbol, name, decimals\nFROM sui_coins_metadata\nWHERE status = 'exists' AND decimals > 6;" }, { "role": "us...
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 character varying(64) NOT NULL, -- unique identifier for the agency agency_name character varying(255) NOT NULL, -- full name of the government agency jurisdiction_level character varying(50) NOT NULL, -- e.g., Federal, State, County, City primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), -- FK to self for hierarchical structure PRIMARY KEY (agency_id) ) CREATE TABLE government_services.applications ( application_id character varying(64) NOT NULL, -- unique identifier for the application citizen_id character varying(64) NOT NULL, -- FK to citizens table service_id character varying(64) NOT NULL, -- FK to services table submitted_at timestamp NOT NULL, -- time the application was submitted status character varying(50) NOT NULL, -- e.g., Submitted, Processing, Approved, Rejected, Pending Info last_updated_at timestamp NOT NULL, -- time the status or details last changed assigned_employee_id character varying(64), -- FK to employees table (optional) decision_date date, -- date when a final decision was made notes text, -- internal notes or citizen-provided comments reference_number character varying(100) UNIQUE, -- publicly visible reference number PRIMARY KEY (application_id) ) CREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, -- unique identifier for the document instance application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly) citizen_id character varying(64) NOT NULL, -- FK to citizens table document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path) upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected verified_by_employee_id character varying(64), -- FK to employees table verification_timestamp timestamp, PRIMARY KEY (document_id) ) CREATE TABLE government_services.payments ( payment_id character varying(64) NOT NULL, -- unique identifier for the payment application_id character varying(64), -- FK to applications table (nullable if payment not for specific app) citizen_id character varying(64) NOT NULL, -- FK to citizens table service_id character varying(64), -- FK to services table (identifies what was paid for) amount numeric(12, 2) NOT NULL, -- amount paid currency character varying(3) NOT NULL DEFAULT 'USD', payment_method character varying(50), -- e.g., Credit Card, Bank Transfer, Check payment_provider_reference character varying(128), -- transaction ID from payment gateway payment_timestamp timestamp NOT NULL, status character varying(30) NOT NULL, -- e.g., Pending, Succeeded, Failed, Refunded notes text, PRIMARY KEY (payment_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.appointments ( appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment citizen_id character varying(64) NOT NULL, -- FK to citizens table employee_id character varying(64), -- FK to employees table (optional, if assigned) location_id character varying(64), -- FK to service_locations table (if physical) service_id character varying(64), -- FK to services table (optional, if related to specific service) scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, -- reason for the appointment status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show booking_method character varying(50), -- e.g., Online, Phone, In-Person created_at timestamp NOT NULL, -- when the appointment was booked notes text, PRIMARY KEY (appointment_id) ) ##Table Structure CREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, application_id character varying(64), citizen_id character varying(64) NOT NULL, document_type character varying(100) NOT NULL, file_reference text NOT NULL, upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', verified_by_employee_id character varying(64), verification_timestamp timestamp, PRIMARY KEY (document_id) ) CREATE TABLE government_services.service_locations ( location_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, location_name character varying(200), 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, contact_phone character varying(32), is_accessible boolean, PRIMARY KEY (location_id) ) ##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.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) )
[ { "role": "user", "content": "List the agency name, location name, address, and contact phone for all accessible service locations in the city of 'Seattle'." }, { "role": "assistant", "content": "SELECT t1.agency_name, t2.location_name, t2.address, t2.contact_phone FROM government_services.agenc...
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.fuel_logs ( fuel_log_id character varying(64) NOT NULL, -- unique identifier for the fuel log entry vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle fueled trip_id character varying(64), -- optional: identifier of the trip during which fueling occurred log_timestamp timestamp with time zone NOT NULL, -- time when fueling occurred fuel_type character varying(32) NOT NULL, -- type of fuel added (matches vehicle's fuel type) quantity numeric(10, 3) NOT NULL, -- amount of fuel added (e.g., Liters, Gallons, kWh) unit character varying(16) NOT NULL, -- unit of quantity (e.g., L, gal, kWh) cost_per_unit numeric(8, 4), -- price per unit of fuel total_cost numeric(10, 2) NOT NULL, -- total cost of the fuel purchase odometer_reading integer, -- vehicle mileage at time of fueling location_id character varying(64), -- identifier of the fueling station/location PRIMARY KEY (fuel_log_id) ) ##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 ) ##Table Structure CREATE TABLE government_services.citizens ( citizen_id text, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean ) CREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text ) CREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text ) ##Table Structure CREATE TABLE legal_services.lawyers ( lawyer_id text PRIMARY KEY, first_name text, last_name text, bar_number text UNIQUE, firm_id text, email text UNIQUE, phone text, specialization text, hire_date timestamp, is_partner bool ) CREATE TABLE legal_services.cases ( case_id text PRIMARY KEY, case_number text UNIQUE, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text ) 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 ) ##Table Structure CREATE TABLE legal_services.lawyers ( lawyer_id character varying(64) NOT NULL, -- unique identifier for the lawyer first_name character varying(100) NOT NULL, -- lawyer's first name last_name character varying(100) NOT NULL, -- lawyer's last name bar_number character varying(64) UNIQUE NOT NULL, -- lawyer's bar association number firm_id character varying(64), -- FK to law_firms table email character varying(128) UNIQUE NOT NULL, -- lawyer's professional email phone character varying(32), -- lawyer's contact phone number specialization text, -- areas of legal expertise hire_date timestamp NOT NULL, -- date the lawyer was hired or joined is_partner boolean DEFAULT false, -- flag indicating if the lawyer is a partner PRIMARY KEY (lawyer_id) ) CREATE TABLE legal_services.law_firms ( firm_id text PRIMARY KEY, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text ) CREATE TABLE legal_services.cases ( case_id text, case_number text, case_name text, client_id text, lead_lawyer_id text, case_type text, status text, date_opened timestamp, date_closed timestamp, description text, court_jurisdiction text ) CREATE TABLE legal_services.appointments ( appointment_id text PRIMARY KEY, 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 ) ##Table Structure CREATE TABLE government_services.employees ( employee_id text, agency_id text, first_name text, last_name text, job_title text, department text, work_email text, work_phone text, hire_date date, termination_date date, access_level text, manager_employee_id text )
[ { "role": "user", "content": "List consecutive fueling events for each vehicle where the refill quantity increased compared to the previous event. Include vehicle_id, previous timestamp and quantity, current timestamp and quantity." }, { "role": "assistant", "content": "SELECT\n prev.vehicle_id...
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 character varying(64) NOT NULL, -- unique identifier for the agency agency_name character varying(255) NOT NULL, -- full name of the government agency jurisdiction_level character varying(50) NOT NULL, -- e.g., Federal, State, County, City primary_contact_email character varying(128), main_phone_number character varying(32), website_url character varying(255), established_date date, parent_agency_id character varying(64), -- FK to self for hierarchical structure PRIMARY KEY (agency_id) ) CREATE TABLE government_services.services ( service_id character varying(64) NOT NULL, -- unique identifier for the service agency_id character varying(64) NOT NULL, -- FK to agencies table service_name character varying(255) NOT NULL, -- name of the service (e.g., Driver's License Renewal) description text, category character varying(100), -- e.g., Licensing, Benefits, Taxation, Permits eligibility_criteria text, -- description of who is eligible standard_fee numeric(10, 2) DEFAULT 0.00, -- typical fee for the service average_processing_time_days integer, -- estimated processing time is_active boolean DEFAULT true, -- whether the service is currently offered online_application_url character varying(255), PRIMARY KEY (service_id) ) CREATE TABLE government_services.applications ( application_id character varying(64) NOT NULL, -- unique identifier for the application citizen_id character varying(64) NOT NULL, -- FK to citizens table service_id character varying(64) NOT NULL, -- FK to services table submitted_at timestamp NOT NULL, -- time the application was submitted status character varying(50) NOT NULL, -- e.g., Submitted, Processing, Approved, Rejected, Pending Info last_updated_at timestamp NOT NULL, -- time the status or details last changed assigned_employee_id character varying(64), -- FK to employees table (optional) decision_date date, -- date when a final decision was made notes text, -- internal notes or citizen-provided comments reference_number character varying(100) UNIQUE, -- publicly visible reference number PRIMARY KEY (application_id) ) CREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, -- unique identifier for the government employee agency_id character varying(64) NOT NULL, -- FK to agencies table 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, -- null if currently employed access_level character varying(50), -- Role or permission level manager_employee_id character varying(64), -- FK to self for reporting structure 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, -- unique identifier for the notification citizen_id character varying(64) NOT NULL, -- FK to citizens table application_id character varying(64), -- FK to applications table (optional) message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, -- e.g., Email, SMS, Portal Message, Mail sent_at timestamp NOT NULL, status character varying(30) NOT NULL, -- e.g., Queued, Sent, Delivered, Failed, Read related_entity_type character varying(50), -- e.g., Application, Appointment, Document Request related_entity_id character varying(64), -- ID of the related entity PRIMARY KEY (notification_id) ) ##Table Structure CREATE TABLE web3.events ( event_id.text, contract_id.text, event_name.text, data.text, emitted_at.timestamp, transaction_id.text, log_index.integer ) CREATE TABLE web3.transactions ( transaction_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128), value numeric(38,14) NOT NULL, gas_used integer NOT NULL, gas_price numeric(38,14) NOT NULL, block_number integer NOT NULL, timestamp timestamp NOT NULL, input_data text, status character varying(32) NOT NULL, nonce integer NOT NULL, PRIMARY KEY (transaction_id) ) CREATE TABLE web3.tokens ( token_id.text, contract_address.text, token_name.text, token_symbol.text, decimals.integer, total_supply.numeric ) CREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp ) CREATE TABLE web3.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp ) ##Table Structure CREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )
[ { "role": "user", "content": "Provide a breakdown of the total number of applications submitted for each service category." }, { "role": "assistant", "content": "SELECT T2.category, count(T1.application_id) FROM applications AS T1 JOIN services AS T2 ON T1.service_id = T2.service_id GROUP BY T2....
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 trading_platform.wallets ( wallet_id.text, user_id.text, address.text, private_key.text, created_at.timestamp ) CREATE TABLE trading_platform.orders ( order_id.text, user_id.text, wallet_id.text, asset_id.text, order_type.text, quantity.numeric, price.numeric, status.text, created_at.timestamp ) ##Table Structure CREATE TABLE hospitality_technology.properties ( property_id character varying(64) NOT NULL, property_name character varying(255) NOT NULL, address_line1 character varying(255) NOT NULL, address_line2 character varying(255), city character varying(100) NOT NULL, state_province character varying(100), postal_code character varying(20) NOT NULL, country_code character varying(3) NOT NULL, phone_number character varying(30), email_address character varying(255), property_type character varying(50) NOT NULL, star_rating numeric(2,1), timezone character varying(64) NOT NULL, manager_staff_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 (property_id) ) CREATE TABLE hospitality_technology.rooms ( room_id character varying(64) NOT NULL, -- unique identifier for the room property_id character varying(64) NOT NULL, -- FK to properties table room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B') room_type_id character varying(64) NOT NULL, -- FK to room_types table floor integer, -- floor number the room is on status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi) current_condition text, -- notes on room condition last_cleaned_at timestamp with time zone, -- timestamp of last cleaning PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) ) 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 PRIMARY KEY, 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.services ( service_id character varying(64) NOT NULL, property_id character varying(64) NOT NULL, service_name character varying(150) NOT NULL, description text, category character varying(100), price numeric(10, 2) NOT NULL, unit character varying(30), is_available boolean NOT NULL DEFAULT true, department character varying(100), PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) ) CREATE TABLE hospitality_technology.payments ( payment_id.text, reservation_id.text, guest_id.text, bill_id.text, amount.numeric, currency_code.text, payment_method.text, card_type.text, card_last_four.text, transaction_ref.text, payment_timestamp.timestamp, status.text, staff_id_processed.text, notes.text ) CREATE TABLE hospitality_technology.reviews ( review_id text PRIMARY KEY, property_id text, reservation_id text, guest_id text, rating_overall int, rating_cleanliness int, rating_service int, rating_location int, rating_value int, comment text, review_source text, review_date timestamp, is_public boolean, staff_response text, response_staff_id text, response_date timestamp ) ##Table Structure CREATE TABLE social_media.hashtags ( hashtag_id.text, tag_name.text, created_at.timestamp ) CREATE TABLE social_media.notifications ( notification_id.text, recipient_user_id.text, sender_user_id.text, notification_type.text, target_entity_id.text, target_entity_type.text, created_at.timestamp, read_at.timestamp ) CREATE TABLE social_media.user_settings ( setting_id.text, user_id.text, theme.text, email_notifications_enabled.boolean, push_notifications_enabled.boolean, private_profile.boolean, updated_at.timestamp ) ##Table Structure CREATE TABLE trading_platform.orders ( order_id text, user_id text, wallet_id text, asset_id text, order_type text, quantity numeric, price numeric, status text, created_at timestamp ) CREATE TABLE trading_platform.metadata ( metadata_id character varying(64) NOT NULL, asset_id character varying(64) NOT NULL, key character varying(128) NOT NULL, value text NOT NULL, PRIMARY KEY (metadata_id) ) ##Table Structure CREATE TABLE insurance.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address_line1 text, address_line2 text, city text, state text, zip_code text, country text, phone_number text, email text, created_at timestamp, updated_at timestamp, status text ) CREATE TABLE insurance.policies ( policy_id text, customer_id text, product_id text, agent_id text, policy_number text, start_date date, end_date date, premium_amount numeric, coverage_limit numeric, deductible numeric, status text, issued_at timestamp, cancellation_date date, cancellation_reason text ) CREATE TABLE insurance.insurance_products ( product_id text, 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 ) CREATE TABLE insurance.premium_payments ( payment_id text, policy_id text, customer_id text, payment_date timestamp, amount_paid numeric, payment_method text, transaction_reference text, due_date date, payment_period_start date, payment_period_end date, status text ) CREATE TABLE insurance.claim_documents ( document_id text, claim_id text, document_type text, file_name text, file_path text, file_size_bytes integer, mime_type text, uploaded_by text, uploaded_at timestamp, description text ) CREATE TABLE insurance.policy_beneficiaries ( beneficiary_id text, policy_id text, customer_id text, first_name text, last_name text, relationship text, percentage_share numeric, contact_info text, added_at timestamp ) ##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 ) ##Table Structure CREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text )
[ { "role": "user", "content": "Show the number of wallets created each month in 2024, showing the year and month." }, { "role": "assistant", "content": "SELECT EXTRACT(YEAR FROM created_at) AS year, EXTRACT(MONTH FROM created_at) AS month, COUNT(*) FROM wallets WHERE EXTRACT(YEAR FROM created_at)...
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_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer ) CREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, -- Block number containing the transaction block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the transaction transaction_index integer NOT NULL, -- Index of the transaction within the block transaction_hash varchar(66) NOT NULL, -- Transaction hash log_index integer NOT NULL, -- Log index contract_address varchar(42) NOT NULL -- Event contract address ) CREATE TABLE erc20_balances ( block_number bigint NOT NULL, -- Block number containing the transaction contract_address varchar NOT NULL, -- Event contract address wallet_address varchar NOT NULL, -- The wallet address for the contract amount varchar NOT NULL, -- Wallet's on-chain balance at the corresponding block height pk varchar NOT NULL -- The last string partition of the contract. ) CREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, contract_address varchar NOT NULL, wallet_address varchar NOT NULL, amount varchar NOT NULL, pk integer NOT NULL ) CREATE TABLE nft_holders ( block_number bigint, contract_address text, wallet_address text, token_id text, contract_type text, amount text, pk text ) CREATE TABLE sui_coins ( object_id.text, status.text, coin_type.text, balance.text, owner.text ) CREATE TABLE sui_coins_metadata ( object_id varchar, coin_type varchar, status varchar, decimals bigint, description varchar, icon_url varchar, symbol varchar, name varchar ) CREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar ) CREATE TABLE nft_collections ( blockchain varchar NOT NULL, -- blockchain fields for the functionType in contract contract_address varchar NOT NULL, -- Contract address(with bloom filter) name varchar NOT NULL, -- name fields for the functionType in contract symbol varchar NOT NULL, -- symbol fields for the functionType in contract deploy_block_number bigint NOT NULL, -- deploy_block_number fields for the functionType in contract deploy_block_time bigint NOT NULL, -- deploy_block_time fields for the functionType in contract erc_type varchar NOT NULL, -- The type of token owner varchar NOT NULL, -- owner fields for the functionType in contract traits varchar NOT NULL, -- traits fields for the functionType in contract description varchar NOT NULL, -- description fields for the functionType in contract slug varchar NOT NULL, -- slug fields for the functionType in contract media_info varchar NOT NULL, -- media_info fields for the functionType in contract image_url varchar NOT NULL, -- image_url fields for the functionType in contract banner_image_url varchar NOT NULL, -- banner_image_url fields for the functionType in contract updated_at bigint NOT NULL, -- updated_at fields for the functionType in contract banner varchar NOT NULL, -- banner fields for the functionType in contract token_count bigint NOT NULL, -- token_count fields for the functionType in contract floor_price varchar NOT NULL, -- floor_price fields for the functionType in contract floor_price_symbol varchar NOT NULL, -- floor_price_symbol fields for the functionType in contract floor_price_contract varchar NOT NULL, -- floor_price_contract fields for the functionType in contract pk integer NOT NULL -- Partition key for the table(floor(deploy_block_time / 1000 / 86400 / 30)) ) CREATE TABLE token_prices ( uuid varchar(36) NOT NULL, -- uuid fields for the functionType in contract blockchain varchar(36) NOT NULL, -- blockchain fields for the functionType in contract address varchar(42) NOT NULL, -- address fields for the functionType in contract decimals bigint NOT NULL, -- decimals fields for the functionType in contract symbol varchar(36) NOT NULL, -- symbol fields for the functionType in contract price real NOT NULL, -- price fields for the functionType in contract timestamp timestamp(6) NOT NULL -- timestamp fields for the functionType in contract ) CREATE TABLE token_prices_latest ( blockchain text, address text, decimals bigint, symbol text, price real, timestamp timestamp ) CREATE TABLE token_info ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text ) CREATE TABLE token_activities ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text ) CREATE TABLE token_balances_bitcoin ( block_number bigint NOT NULL, -- Block number containing the transaction block_timestamp timestamp(3) NOT NULL, -- Block timestamp containing the transaction tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription wallet_address varchar(42) NOT NULL, -- Address of owner total_supply varchar NOT NULL, -- Max supply: Set max supply of the inscription amount varchar NOT NULL -- The balance of wallet balance at the corresponding block height ) CREATE TABLE token_info_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(255) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL ) CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table) block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table) tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table) tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table) log_index integer NOT NULL, -- Index of the log within the transaction type varchar(20) NOT NULL, -- Operation: Type of event (deploy, mint, transfer, list) tick varchar(255) NOT NULL, -- Ticker: Identifier of the inscription id varchar(255) NOT NULL, -- Unique identifier of the inscription amt decimal(38,0) NOT NULL, -- Amount to mint: States the amount of the inscription to operation. When operation is mint, has to be less or equal to "lim" from_address varchar(62) NOT NULL, -- Address sending the inscription to_address varchar(62) NOT NULL -- Address receiving the inscription ) CREATE TABLE token_activities_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text ) CREATE TABLE token_balances_avalanche ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, tick varchar(20) NOT NULL, wallet_address varchar(42) NOT NULL, total_supply decimal(38,0) NOT NULL, amount decimal(38,0) NOT NULL ) CREATE TABLE token_info_avalanche ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, tick.text, max_supply.decimal, lim.decimal, wlim.decimal, dec.integer, creator.text, minted.decimal, holders.decimal, txs.decimal, updated_timestamp.timestamp, completed_timestamp.timestamp, id.text )
[ { "role": "user", "content": "Show me wallet addresses that hold more than 1000 of any ERC20 token, along with the token symbol and amount." }, { "role": "assistant", "content": "SELECT eb.wallet_address, tm.symbol, eb.amount FROM erc20_balances eb JOIN token_metas tm ON eb.contract_address = tm...
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 text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text ) CREATE TABLE transportation.trips ( trip_id character varying(64) NOT NULL, -- unique identifier for a specific trip instance route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips) vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used driver_id character varying(64) NOT NULL, -- identifier of the driver operating scheduled_departure timestamp with time zone NOT NULL, -- planned departure time actual_departure timestamp with time zone, -- actual departure time scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time actual_arrival timestamp with time zone, -- actual arrival time origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin) destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination) status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled passenger_count integer, -- number of passengers (if applicable) cargo_manifest_id character varying(64), -- link to cargo details (if applicable) PRIMARY KEY (trip_id) ) CREATE TABLE transportation.locations ( location_id text, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text ) CREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date ) ##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.lawyers ( lawyer_id text PRIMARY KEY, first_name text, last_name text, bar_number text UNIQUE, firm_id text, email text UNIQUE, phone text, specialization text, hire_date timestamp, is_partner bool ) CREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text ) 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.time_entries ( entry_id character varying(64) NOT NULL, -- unique identifier for the time entry case_id character varying(64) NOT NULL, -- FK to cases table lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work) date_worked date NOT NULL, -- date the work was performed hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m) billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry description text NOT NULL, -- detailed description of the work performed is_billable boolean DEFAULT true, -- whether this time entry is billable to the client is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice invoice_id character varying(64), -- FK to invoices table (once billed) created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded PRIMARY KEY (entry_id) ) CREATE TABLE legal_services.invoices ( invoice_id text PRIMARY KEY, invoice_number text UNIQUE, client_id text, case_id text, issue_date date, due_date date, total_amount numeric, amount_paid numeric, status text, payment_date timestamp, notes text, created_at timestamp ) CREATE TABLE legal_services.appointments ( appointment_id text PRIMARY KEY, 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 ) ##Table Structure CREATE TABLE trading_platform.orders ( order_id.text, user_id.text, wallet_id.text, asset_id.text, order_type.text, quantity.numeric, price.numeric, status.text, created_at.timestamp ) ##Table Structure CREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean ) CREATE TABLE government_services.notifications ( notification_id text PRIMARY KEY, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text )
[ { "role": "user", "content": "List all maintenance logs for vehicles that had 'Oil Change' service in the last 3 months, showing vehicle ID, service date, and cost." }, { "role": "assistant", "content": "SELECT vehicle_id, service_date, cost FROM transportation.maintenance_logs WHERE service_typ...
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_metas ( block_timestamp timestamp, block_number bigint, transaction_hash varchar, transaction_index bigint, from_address varchar, contract_address varchar, symbol varchar, total_supply varchar, name varchar, decimals bigint, is_erc20 integer, is_erc721 integer, is_erc1155 integer, is_proxy integer, extra_info varchar, pk integer ) CREATE TABLE erc1155_approval_for_all ( block_number bigint NOT NULL, block_timestamp timestamp(3) NOT NULL, transaction_index integer NOT NULL, transaction_hash varchar(66) NOT NULL, log_index integer NOT NULL, contract_address varchar(42) NOT NULL ) CREATE TABLE erc20_balances ( block_number.bigint, contract_address.text, wallet_address.text, amount.text, pk.text ) CREATE TABLE erc20_balances_historical ( block_number bigint NOT NULL, -- Block number containing the transaction contract_address varchar NOT NULL, -- Event contract address wallet_address varchar NOT NULL, -- The wallet address for the contract amount varchar NOT NULL, -- Wallet's on-chain balance at the corresponding block height pk integer NOT NULL -- Partition key for the table(floor(block_number / 7200)) ) CREATE TABLE nft_holders ( block_number bigint NOT NULL, -- Block number containing the transaction contract_address varchar NOT NULL, -- Event contract address wallet_address varchar NOT NULL, -- The wallet address for the contract(with bloom filter) token_id varchar NOT NULL, -- NFT token id contract_type varchar NOT NULL, -- NFT contract type amount varchar NOT NULL, -- Number of held NFTs pk varchar NOT NULL -- The last string partition of the contract. ) CREATE TABLE nft_holder_historical ( block_number.bigint, contract_address.text, wallet_address.text, token_id.text, contract_type.text, amount.text, pk.integer ) CREATE TABLE sui_coins ( object_id text, status text, coin_type text, balance text, owner text ) CREATE TABLE sui_coins_metadata ( object_id varchar, coin_type varchar, status varchar, decimals bigint, description varchar, icon_url varchar, symbol varchar, name varchar ) CREATE TABLE sui_nfts ( object_id varchar, status varchar, collection_type varchar, package_id varchar, previous_transaction varchar, display varchar, owner varchar, name varchar ) CREATE TABLE nft_collections ( blockchain varchar NOT NULL, -- blockchain fields for the functionType in contract contract_address varchar NOT NULL, -- Contract address(with bloom filter) name varchar NOT NULL, -- name fields for the functionType in contract symbol varchar NOT NULL, -- symbol fields for the functionType in contract deploy_block_number bigint NOT NULL, -- deploy_block_number fields for the functionType in contract deploy_block_time bigint NOT NULL, -- deploy_block_time fields for the functionType in contract erc_type varchar NOT NULL, -- The type of token owner varchar NOT NULL, -- owner fields for the functionType in contract traits varchar NOT NULL, -- traits fields for the functionType in contract description varchar NOT NULL, -- description fields for the functionType in contract slug varchar NOT NULL, -- slug fields for the functionType in contract media_info varchar NOT NULL, -- media_info fields for the functionType in contract image_url varchar NOT NULL, -- image_url fields for the functionType in contract banner_image_url varchar NOT NULL, -- banner_image_url fields for the functionType in contract updated_at bigint NOT NULL, -- updated_at fields for the functionType in contract banner varchar NOT NULL, -- banner fields for the functionType in contract token_count bigint NOT NULL, -- token_count fields for the functionType in contract floor_price varchar NOT NULL, -- floor_price fields for the functionType in contract floor_price_symbol varchar NOT NULL, -- floor_price_symbol fields for the functionType in contract floor_price_contract varchar NOT NULL, -- floor_price_contract fields for the functionType in contract pk integer NOT NULL -- Partition key for the table(floor(deploy_block_time / 1000 / 86400 / 30)) ) CREATE TABLE token_prices ( uuid varchar, blockchain varchar, address varchar, decimals bigint, symbol varchar, price real, timestamp timestamp ) CREATE TABLE token_prices_latest ( blockchain varchar(36) NOT NULL, -- blockchain fields for the functionType in contract address varchar(42) NOT NULL, -- address fields for the functionType in contract decimals bigint NOT NULL, -- decimals fields for the functionType in contract symbol varchar(36) NOT NULL, -- symbol fields for the functionType in contract price real NOT NULL, -- price fields for the functionType in contract timestamp timestamp(6) NOT NULL -- timestamp fields for the functionType in contract ) CREATE TABLE erc20_approval ( block_number bigint, block_timestamp timestamp, transaction_index integer, transaction_hash text, log_index integer, contract_address text, pk integer ) CREATE TABLE token_balances ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal ) CREATE TABLE token_info ( block_timestamp timestamp(3) NOT NULL, -- Timestamp of the block containing the inscription (matches block_timestamp in transactions table) block_number bigint NOT NULL, -- Block number containing the inscription (matches block_number in transactions table) tx_index integer NOT NULL, -- Index of the transaction containing the inscription (matches transaction_index in transactions table) tx_hash varchar(66) NOT NULL, -- Unique identifier of the transaction containing the inscription (matches hash in transactions table) tick varchar NOT NULL, -- Token tick max_supply decimal(38,0) NOT NULL, -- Max supply lim decimal(38,0) NOT NULL, -- Limit of each mint wlim decimal(38,0) NOT NULL, -- Limit of each address can maximum mint dec integer NOT NULL, -- Decimal for minimum divie creator varchar(42) NOT NULL -- Address originating the inscription (matches from_address in transactions table) ) CREATE TABLE token_activities ( block_timestamp.timestamp, block_number.bigint, tx_index.integer, tx_hash.text, log_index.integer, type.text, tick.text, id.text, amt.decimal, from_address.text, to_address.text ) CREATE TABLE mud_holesky_redstone ( address.text, table_id.text, key_bytes.text, key0.text, key1.text, static_data.text, encoded_lengths.text, dynamic_data.text, is_deleted.boolean, block_number.bigint, log_index.bigint ) CREATE TABLE token_balances_bitcoin ( block_number bigint, block_timestamp timestamp, tick varchar, wallet_address varchar, total_supply varchar, amount varchar ) CREATE TABLE token_info_bitcoin ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, tick varchar(255) NOT NULL, max_supply decimal(38,0) NOT NULL, lim decimal(38,0) NOT NULL, wlim decimal(38,0) NOT NULL, dec integer NOT NULL, creator varchar(42) NOT NULL ) CREATE TABLE token_activities_bitcoin ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, log_index integer, type text, tick text, id text, amt decimal, from_address text, to_address text ) CREATE TABLE token_activities_avalanche ( block_timestamp timestamp(3) NOT NULL, block_number bigint NOT NULL, tx_index integer NOT NULL, tx_hash varchar(66) NOT NULL, log_index integer NOT NULL, type varchar(20) NOT NULL, tick varchar(255) NOT NULL, id varchar(255) NOT NULL, amt decimal(38,0) NOT NULL, from_address varchar(42) NOT NULL, to_address varchar(42) NOT NULL ) CREATE TABLE token_balances_avalanche ( block_number bigint, block_timestamp timestamp, tick text, wallet_address text, total_supply decimal, amount decimal ) CREATE TABLE token_info_avalanche ( block_timestamp timestamp, block_number bigint, tx_index integer, tx_hash text, tick text, max_supply decimal, lim decimal, wlim decimal, dec integer, creator text, minted decimal, holders decimal, txs decimal, updated_timestamp timestamp, completed_timestamp timestamp, id text )
[ { "role": "user", "content": "Show me the current amount held and wallet address for all wallets holding more than 100,000 units of the ERC20 token with contract address '0xeeee...'." }, { "role": "assistant", "content": "SELECT wallet_address, amount FROM erc20_balances WHERE contract_address =...
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, -- unique identifier for the user username character varying(50) NOT NULL UNIQUE, -- user's unique handle email character varying(128) NOT NULL UNIQUE, -- user's email address password_hash text NOT NULL, -- hashed password full_name character varying(100), -- user's full name profile_picture_url text, -- URL to the profile picture bio text, -- short user biography location character varying(100), -- user's location created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of account creation updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last profile update is_verified boolean NOT NULL DEFAULT false, -- verification status PRIMARY KEY (user_id) ) CREATE TABLE social_media.posts ( post_id character varying(64) NOT NULL, -- unique identifier for the post user_id character varying(64) NOT NULL, -- identifier of the user who created the post (FK to users.user_id) content text, -- textual content of the post media_url text, -- URL to attached media (image/video) media_type character varying(20), -- type of media ('image', 'video', null) created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of post creation updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last post edit visibility character varying(20) NOT NULL DEFAULT 'public', -- visibility ('public', 'friends', 'private') location_lat numeric(9,6), -- latitude of post location location_lon numeric(9,6), -- longitude of post location PRIMARY KEY (post_id) ) CREATE TABLE social_media.likes ( like_id character varying(64) NOT NULL, -- unique identifier for the like user_id character varying(64) NOT NULL, -- identifier of the user who liked (FK to users.user_id) post_id character varying(64), -- identifier of the post being liked (FK to posts.post_id, nullable) comment_id character varying(64), -- identifier of the comment being liked (FK to comments.comment_id, nullable) created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the like occurred PRIMARY KEY (like_id), CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), -- prevent duplicate likes CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) -- ensure it likes something ) CREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, -- unique identifier for the follow relationship follower_user_id character varying(64) NOT NULL, -- identifier of the user who is following (FK to users.user_id) following_user_id character varying(64) NOT NULL, -- identifier of the user being followed (FK to users.user_id) created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the follow started PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) -- prevent duplicate follows ) CREATE TABLE social_media.post_hashtags ( post_hashtag_id character varying(64) NOT NULL, -- unique identifier for the post-hashtag link post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id) hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id) PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post ) CREATE TABLE social_media.messages ( message_id character varying(64) NOT NULL, -- unique identifier for the message conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id) sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id) content text, -- textual content of the message media_url text, -- URL to attached media (image/video) media_type character varying(20), -- type of media ('image', 'video', null) sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent read_at timestamp, -- timestamp when message was read by recipient(s) PRIMARY KEY (message_id) ) CREATE TABLE social_media.conversations ( conversation_id character varying(64) NOT NULL, -- unique identifier for the conversation created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when conversation was initiated last_message_at timestamp, -- timestamp of the last message in the conversation is_group_chat boolean NOT NULL DEFAULT false, -- indicates if it's a group chat or direct message group_name character varying(100), -- name of the group chat (if applicable) PRIMARY KEY (conversation_id) ) CREATE TABLE social_media.conversation_participants ( participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id) user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id) joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation last_read_at timestamp, -- timestamp indicating up to when the user has read messages PRIMARY KEY (participant_id), CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times ) CREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, -- unique identifier for the notification recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id) sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications) notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message') target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id) target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation') created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created read_at timestamp, -- timestamp notification was marked as read PRIMARY KEY (notification_id) ) CREATE TABLE social_media.user_settings ( setting_id character varying(64) NOT NULL, -- unique identifier for the setting entry user_id character varying(64) NOT NULL UNIQUE, -- user the settings belong to (FK to users.user_id) theme character varying(20) DEFAULT 'light', -- UI theme ('light', 'dark') email_notifications_enabled boolean DEFAULT true, -- enable/disable email notifications push_notifications_enabled boolean DEFAULT true, -- enable/disable push notifications private_profile boolean DEFAULT false, -- is the user profile private updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last setting change PRIMARY KEY (setting_id) ) ##Table Structure CREATE TABLE government_services.citizens ( citizen_id text PRIMARY KEY, national_id_number text, first_name text, last_name text, date_of_birth date, gender text, primary_address text, contact_email text, contact_phone text, registration_date timestamp, is_verified boolean ) ##Table Structure CREATE TABLE gaming_technology.player_inventory ( inventory_id uuid, player_id uuid, item_id uuid, quantity integer, acquired_at timestamp with time zone, instance_data jsonb )
[ { "role": "user", "content": "List each conversation_id and the number of unread messages (where read_at is null)." }, { "role": "assistant", "content": "SELECT m.conversation_id, COUNT(*) AS unread_messages FROM social_media.messages m WHERE m.read_at IS NULL GROUP BY m.conversation_id;" }, ...
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 ) CREATE TABLE social_media.follows ( follow_id character varying(64) NOT NULL, -- unique identifier for the follow relationship follower_user_id character varying(64) NOT NULL, -- identifier of the user who is following (FK to users.user_id) following_user_id character varying(64) NOT NULL, -- identifier of the user being followed (FK to users.user_id) created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of when the follow started PRIMARY KEY (follow_id), CONSTRAINT unique_follow UNIQUE (follower_user_id, following_user_id) -- prevent duplicate follows ) 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, -- unique identifier for the post-hashtag link post_id character varying(64) NOT NULL, -- identifier of the post (FK to posts.post_id) hashtag_id character varying(64) NOT NULL, -- identifier of the hashtag (FK to hashtags.hashtag_id) PRIMARY KEY (post_hashtag_id), CONSTRAINT unique_post_hashtag UNIQUE (post_id, hashtag_id) -- prevent duplicate tags on a post ) CREATE TABLE social_media.messages ( message_id character varying(64) NOT NULL, -- unique identifier for the message conversation_id character varying(64) NOT NULL, -- identifier for the conversation thread (FK to conversations.conversation_id) sender_user_id character varying(64) NOT NULL, -- identifier of the sender (FK to users.user_id) content text, -- textual content of the message media_url text, -- URL to attached media (image/video) media_type character varying(20), -- type of media ('image', 'video', null) sent_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when message was sent read_at timestamp, -- timestamp when message was read by recipient(s) PRIMARY KEY (message_id) ) CREATE TABLE social_media.conversations ( conversation_id text PRIMARY KEY, created_at timestamp, last_message_at timestamp, is_group_chat bool, group_name text ) CREATE TABLE social_media.conversation_participants ( participant_id character varying(64) NOT NULL, -- unique identifier for the participant entry conversation_id character varying(64) NOT NULL, -- identifier of the conversation (FK to conversations.conversation_id) user_id character varying(64) NOT NULL, -- identifier of the user in the conversation (FK to users.user_id) joined_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp when user joined the conversation last_read_at timestamp, -- timestamp indicating up to when the user has read messages PRIMARY KEY (participant_id), CONSTRAINT unique_user_conversation UNIQUE (conversation_id, user_id) -- prevent user being added multiple times ) CREATE TABLE social_media.notifications ( notification_id character varying(64) NOT NULL, -- unique identifier for the notification recipient_user_id character varying(64) NOT NULL, -- user receiving the notification (FK to users.user_id) sender_user_id character varying(64), -- user triggering the notification (FK to users.user_id, can be null for system notifications) notification_type character varying(30) NOT NULL, -- type of notification ('like', 'comment', 'follow', 'mention', 'message') target_entity_id character varying(64), -- ID of the related entity (post_id, comment_id, user_id, conversation_id) target_entity_type character varying(20), -- type of the related entity ('post', 'comment', 'user', 'conversation') created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp notification was created read_at timestamp, -- timestamp notification was marked as read 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) ) ##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.services ( service_id character varying(64) NOT NULL, agency_id character varying(64) NOT NULL, service_name character varying(255) NOT NULL, description text, category character varying(100), eligibility_criteria text, standard_fee numeric(10, 2) DEFAULT 0.00, average_processing_time_days integer, is_active boolean DEFAULT true, online_application_url character varying(255), PRIMARY KEY (service_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.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) ) ##Table Structure CREATE TABLE insurance.claims ( claim_id text, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text ) CREATE TABLE insurance.claim_documents ( document_id text PRIMARY KEY, claim_id text, document_type text, file_name text, file_path text, file_size_bytes int, mime_type text, uploaded_by text, uploaded_at timestamp, description text ) ##Table Structure CREATE TABLE insurance.agents ( agent_id text PRIMARY KEY, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text )
[ { "role": "user", "content": "List all post IDs and their corresponding hashtag names for posts that include media." }, { "role": "assistant", "content": "SELECT ph.post_id, h.tag_name\nFROM social_media.post_hashtags ph\nJOIN social_media.hashtags h ON ph.hashtag_id = h.hashtag_id\nJOIN social_...
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.vehicles ( vehicle_id character varying(64) NOT NULL, -- unique identifier for the vehicle license_plate character varying(32) NOT NULL UNIQUE, -- vehicle license plate vin character varying(17) UNIQUE, -- vehicle identification number make character varying(64) NOT NULL, -- manufacturer of the vehicle model character varying(64) NOT NULL, -- model of the vehicle year integer NOT NULL, -- manufacturing year type character varying(32) NOT NULL, -- type of vehicle (e.g., Bus, Train, Truck, Car, Van) capacity integer, -- passenger or cargo capacity fuel_type character varying(32) NOT NULL, -- e.g., Diesel, Gasoline, Electric, Hydrogen status character varying(32) NOT NULL, -- e.g., Active, Maintenance, Decommissioned depot_id character varying(64), -- identifier of the home depot/base acquisition_date date, -- date the vehicle was acquired PRIMARY KEY (vehicle_id) ) CREATE TABLE transportation.drivers ( driver_id.text, employee_id.text, first_name.text, last_name.text, license_number.text, license_expiry_date.date, contact_number.text, email.text, hire_date.date, status.text ) CREATE TABLE transportation.routes ( route_id.text, route_number.text, description.text, origin_location_id.text, destination_location_id.text, distance_km.numeric, estimated_duration_minutes.integer, type.text ) CREATE TABLE transportation.maintenance_logs ( log_id text PRIMARY KEY, vehicle_id text, service_date date, odometer_reading int, service_type text, description text, cost numeric, mechanic_name text, next_service_due_date date ) CREATE TABLE transportation.passengers ( passenger_id.text, first_name.text, last_name.text, email.text, phone_number.text, date_of_birth.date, loyalty_program_id.text, created_at.timestamp ) ##Table Structure CREATE TABLE legal_services.appointments ( appointment_id text PRIMARY KEY, 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 ) ##Table Structure CREATE TABLE insurance.claims ( claim_id.text, policy_id.text, customer_id.text, incident_date.timestamp, reported_date.timestamp, description.text, estimated_loss.numeric, status.text, settlement_amount.numeric, settlement_date.date, claim_handler_id.text, police_report_number.text ) ##Table Structure 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.services ( service_id.text, agency_id.text, service_name.text, description.text, category.text, eligibility_criteria.text, standard_fee.numeric, average_processing_time_days.integer, is_active.boolean, online_application_url.text ) CREATE TABLE government_services.applications ( application_id.text, citizen_id.text, service_id.text, submitted_at.timestamp, status.text, last_updated_at.timestamp, assigned_employee_id.text, decision_date.date, notes.text, reference_number.text ) 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.text, agency_id.text, first_name.text, last_name.text, job_title.text, department.text, work_email.text, work_phone.text, hire_date.date, termination_date.date, access_level.text, manager_employee_id.text ) CREATE TABLE government_services.service_locations ( location_id.text, agency_id.text, location_name.text, address.text, city.text, state.text, postal_code.text, latitude.numeric, longitude.numeric, operating_hours.text, contact_phone.text, is_accessible.boolean ) CREATE TABLE government_services.appointments ( appointment_id.text, citizen_id.text, employee_id.text, location_id.text, service_id.text, scheduled_start_time.timestamp, scheduled_end_time.timestamp, purpose.text, status.text, booking_method.text, created_at.timestamp, notes.text ) CREATE TABLE government_services.notifications ( notification_id.text, citizen_id.text, application_id.text, message_subject.text, message_body.text, channel.text, sent_at.timestamp, status.text, related_entity_type.text, related_entity_id.text ) ##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 ) ##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 ) CREATE TABLE social_media.likes ( like_id character varying(64) NOT NULL, user_id character varying(64) NOT NULL, post_id character varying(64), comment_id character varying(64), created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (like_id), CONSTRAINT unique_user_like UNIQUE (user_id, post_id, comment_id), CONSTRAINT check_like_target CHECK (post_id IS NOT NULL OR comment_id IS NOT NULL) ) CREATE TABLE social_media.conversations ( conversation_id.text, created_at.timestamp, last_message_at.timestamp, is_group_chat.boolean, group_name.text ) CREATE TABLE social_media.notifications ( notification_id text PRIMARY KEY, recipient_user_id text, sender_user_id text, notification_type text, target_entity_id text, target_entity_type text, created_at timestamp, read_at timestamp ) ##Table Structure CREATE TABLE healthcare.insurance_plans ( plan_id text PRIMARY KEY, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )
[ { "role": "user", "content": "Show the average maintenance cost for vehicles of each make, including only vehicles that have had at least one maintenance log." }, { "role": "assistant", "content": "SELECT v.make, AVG(ml.cost) AS average_maintenance_cost FROM transportation.vehicles AS v JOIN tra...
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.text, username.text, email.text, password_hash.text, full_name.text, profile_picture_url.text, bio.text, location.text, created_at.timestamp, updated_at.timestamp, is_verified.boolean ) CREATE TABLE social_media.posts ( post_id.text, 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 ) CREATE TABLE social_media.comments ( comment_id.text, post_id.text, user_id.text, parent_comment_id.text, content.text, created_at.timestamp, updated_at.timestamp ) CREATE TABLE social_media.likes ( like_id.text, user_id.text, post_id.text, comment_id.text, created_at.timestamp ) CREATE TABLE social_media.follows ( follow_id.text, follower_user_id.text, following_user_id.text, created_at.timestamp ) CREATE TABLE social_media.conversation_participants ( participant_id.text, conversation_id.text, user_id.text, joined_at.timestamp, last_read_at.timestamp ) ##Table Structure CREATE TABLE transportation.routes ( route_id text, route_number text, description text, origin_location_id text, destination_location_id text, distance_km numeric, estimated_duration_minutes integer, type text ) CREATE TABLE transportation.trips ( trip_id character varying(64) NOT NULL, -- unique identifier for a specific trip instance route_id character varying(64), -- identifier of the route being followed (can be null for ad-hoc trips) vehicle_id character varying(64) NOT NULL, -- identifier of the vehicle used driver_id character varying(64) NOT NULL, -- identifier of the driver operating scheduled_departure timestamp with time zone NOT NULL, -- planned departure time actual_departure timestamp with time zone, -- actual departure time scheduled_arrival timestamp with time zone NOT NULL, -- planned arrival time actual_arrival timestamp with time zone, -- actual arrival time origin_location_id character varying(64) NOT NULL, -- actual starting location (could differ from route origin) destination_location_id character varying(64) NOT NULL, -- actual ending location (could differ from route destination) status character varying(32) NOT NULL, -- e.g., Scheduled, In Progress, Completed, Delayed, Cancelled passenger_count integer, -- number of passengers (if applicable) cargo_manifest_id character varying(64), -- link to cargo details (if applicable) PRIMARY KEY (trip_id) ) CREATE TABLE transportation.fuel_logs ( fuel_log_id text PRIMARY KEY, vehicle_id text, trip_id text, log_timestamp timestamp, fuel_type text, quantity numeric, unit text, cost_per_unit numeric, total_cost numeric, odometer_reading int, location_id text ) CREATE TABLE transportation.bookings ( booking_id character varying(64) NOT NULL, -- unique identifier for the booking passenger_id character varying(64) NOT NULL, -- identifier of the passenger making the booking trip_id character varying(64) NOT NULL, -- identifier of the trip being booked seat_number character varying(16), -- assigned seat number (if applicable) booking_time timestamp with time zone NOT NULL, -- time when the booking was made status character varying(32) NOT NULL, -- e.g., Confirmed, Cancelled, Pending Payment fare numeric(10, 2) NOT NULL, -- price paid for the booking payment_transaction_id character varying(128), -- reference to the payment transaction special_requests text, -- any special requests from the passenger PRIMARY KEY (booking_id) ) ##Table Structure CREATE TABLE government_services.documents ( document_id character varying(64) NOT NULL, -- unique identifier for the document instance application_id character varying(64), -- FK to applications table (optional, could be linked to citizen directly) citizen_id character varying(64) NOT NULL, -- FK to citizens table document_type character varying(100) NOT NULL, -- e.g., Passport Scan, Proof of Address, Birth Certificate file_reference text NOT NULL, -- reference to the stored file (e.g., S3 URL, internal path) upload_timestamp timestamp NOT NULL, expiry_date date, verification_status character varying(30) DEFAULT 'Pending', -- e.g., Pending, Verified, Rejected verified_by_employee_id character varying(64), -- FK to employees table verification_timestamp timestamp, PRIMARY KEY (document_id) ) CREATE TABLE government_services.employees ( employee_id character varying(64) NOT NULL, -- unique identifier for the government employee agency_id character varying(64) NOT NULL, -- FK to agencies table 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, -- null if currently employed access_level character varying(50), -- Role or permission level manager_employee_id character varying(64), -- FK to self for reporting structure PRIMARY KEY (employee_id) ) CREATE TABLE government_services.appointments ( appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment citizen_id character varying(64) NOT NULL, -- FK to citizens table employee_id character varying(64), -- FK to employees table (optional, if assigned) location_id character varying(64), -- FK to service_locations table (if physical) service_id character varying(64), -- FK to services table (optional, if related to specific service) scheduled_start_time timestamp NOT NULL, scheduled_end_time timestamp, purpose text NOT NULL, -- reason for the appointment status character varying(30) NOT NULL, -- e.g., Scheduled, Completed, Cancelled, No-Show booking_method character varying(50), -- e.g., Online, Phone, In-Person created_at timestamp NOT NULL, -- when the appointment was booked notes text, PRIMARY KEY (appointment_id) ) CREATE TABLE government_services.notifications ( notification_id character varying(64) NOT NULL, -- unique identifier for the notification citizen_id character varying(64) NOT NULL, -- FK to citizens table application_id character varying(64), -- FK to applications table (optional) message_subject character varying(255), message_body text NOT NULL, channel character varying(30) NOT NULL, -- e.g., Email, SMS, Portal Message, Mail sent_at timestamp NOT NULL, status character varying(30) NOT NULL, -- e.g., Queued, Sent, Delivered, Failed, Read related_entity_type character varying(50), -- e.g., Application, Appointment, Document Request related_entity_id character varying(64), -- ID of the related entity PRIMARY KEY (notification_id) ) ##Table Structure CREATE TABLE transportation.drivers ( driver_id text, employee_id text, first_name text, last_name text, license_number text, license_expiry_date date, contact_number text, email text, hire_date date, status text ) ##Table Structure CREATE TABLE trading_platform.users ( user_id.text, username.text, email.text, password_hash.text, created_at.timestamp )
[ { "role": "user", "content": "Show the usernames and their profile picture URLs for users who have a profile picture set and are also verified." }, { "role": "assistant", "content": "SELECT username, profile_picture_url FROM social_media.users WHERE profile_picture_url IS NOT NULL AND profile_pi...
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 character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.) property_name character varying(255) NOT NULL, -- name of the property address_line1 character varying(255) NOT NULL, -- primary address line address_line2 character varying(255), -- secondary address line city character varying(100) NOT NULL, -- city state_province character varying(100), -- state or province postal_code character varying(20) NOT NULL, -- zip or postal code country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN) phone_number character varying(30), -- main contact phone email_address character varying(255), -- main contact email property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel star_rating numeric(2,1), -- star rating (e.g., 4.5) timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York) manager_staff_id character varying(64), -- FK to staff table for the general manager 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 (property_id) ) CREATE TABLE hospitality_technology.rooms ( room_id character varying(64) NOT NULL, -- unique identifier for the room property_id character varying(64) NOT NULL, -- FK to properties table room_number character varying(10) NOT NULL, -- room number identifier (e.g., '101', 'Suite 2B') room_type_id character varying(64) NOT NULL, -- FK to room_types table floor integer, -- floor number the room is on status character varying(50) NOT NULL, -- e.g., Available, Occupied, Cleaning, OutOfOrder, Maintenance is_smoking boolean NOT NULL DEFAULT false, -- smoking allowed flag features text, -- description of features (e.g., Balcony, Sea View, Jacuzzi) current_condition text, -- notes on room condition last_cleaned_at timestamp with time zone, -- timestamp of last cleaning PRIMARY KEY (room_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (room_type_id) REFERENCES hospitality_technology.room_types(room_type_id) ) CREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, -- unique identifier for the guest profile first_name character varying(100) NOT NULL, -- guest's first name last_name character varying(100) NOT NULL, -- guest's last name email character varying(255) UNIQUE, -- guest's email address (unique identifier?) phone_number character varying(30), -- guest's phone number date_of_birth date, -- guest's date of birth address_line1 character varying(255), -- guest's home address city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, -- notes on guest preferences (e.g., allergies, room location) loyalty_member_id character varying(64) UNIQUE, -- FK to loyalty_members table communication_consent boolean DEFAULT true, -- consent for marketing communications created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) ) CREATE TABLE hospitality_technology.staff ( staff_id character varying(64) NOT NULL, -- unique identifier for the staff member property_id character varying(64) NOT NULL, -- FK to properties table (primary property) first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, position character varying(100) NOT NULL, -- e.g., Front Desk Agent, Housekeeper, Manager, Concierge work_email character varying(255) UNIQUE, -- staff member's work email work_phone character varying(30), hire_date date NOT NULL, termination_date date, -- date employment ended (if applicable) is_active boolean NOT NULL DEFAULT true, -- currently employed flag access_level integer NOT NULL, -- permission level within systems (e.g., 1=basic, 5=admin) manager_id character varying(64), -- FK to staff table (self-referencing for supervisor) created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (staff_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (manager_id) REFERENCES hospitality_technology.staff(staff_id) ) CREATE TABLE hospitality_technology.services ( service_id character varying(64) NOT NULL, -- unique identifier for a chargeable service property_id character varying(64) NOT NULL, -- FK to properties table service_name character varying(150) NOT NULL, -- e.g., Room Service - Burger, Spa - Massage 60min, Laundry - Shirt description text, category character varying(100), -- e.g., Food & Beverage, Wellness, Business Center, Activities price numeric(10, 2) NOT NULL, -- price per unit/instance unit character varying(30), -- e.g., Per Item, Per Hour, Per Day is_available boolean NOT NULL DEFAULT true, -- is the service currently offered? department character varying(100), -- department responsible (e.g., F&B, Spa, Housekeeping) PRIMARY KEY (service_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id) ) CREATE TABLE hospitality_technology.reviews ( review_id character varying(64) NOT NULL, -- unique identifier for the review property_id character varying(64) NOT NULL, -- FK to properties table reservation_id character varying(64) UNIQUE, -- FK to reservations (link review to a specific stay, optional but good) guest_id character varying(64) NOT NULL, -- FK to guests table rating_overall integer, -- overall score (e.g., 1-5 or 1-10) rating_cleanliness integer, rating_service integer, rating_location integer, rating_value integer, comment text, -- guest's written feedback review_source character varying(100), -- e.g., DirectSurvey, TripAdvisor, Google, Booking.com review_date timestamp with time zone NOT NULL DEFAULT current_timestamp, -- when the review was submitted is_public boolean DEFAULT true, -- whether the review is publicly visible staff_response text, -- official response from the property response_staff_id character varying(64), -- FK to staff (who responded) response_date timestamp with time zone, -- when the response was posted PRIMARY KEY (review_id), FOREIGN KEY (property_id) REFERENCES hospitality_technology.properties(property_id), FOREIGN KEY (reservation_id) REFERENCES hospitality_technology.reservations(reservation_id), FOREIGN KEY (guest_id) REFERENCES hospitality_technology.guests(guest_id), FOREIGN KEY (response_staff_id) REFERENCES hospitality_technology.staff(staff_id) ) ##Table Structure CREATE TABLE web3.token_transfers ( transfer_id character varying(64) NOT NULL, -- unique identifier for the transfer token_id character varying(64) NOT NULL, -- identifier of the token being transferred from_address character varying(128) NOT NULL, -- address of the sender to_address character varying(128) NOT NULL, -- address of the receiver value numeric(38,14) NOT NULL, -- amount of tokens transferred transaction_id character varying(64) NOT NULL, -- identifier of the transaction containing the transfer log_index integer NOT NULL, -- index of the transfer log in the transaction PRIMARY KEY (transfer_id) )
[ { "role": "user", "content": "List each property name with the count of active staff members currently employed at that property." }, { "role": "assistant", "content": "SELECT p.property_name, COUNT(s.staff_id) AS active_staff_count\nFROM hospitality_technology.properties p\nLEFT JOIN hospitalit...
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.vehicles ( vehicle_id.text, license_plate.text, vin.text, make.text, model.text, year.integer, type.text, capacity.integer, fuel_type.text, status.text, depot_id.text, acquisition_date.date ) ##Table Structure CREATE TABLE healthcare.patients ( patient_id.text, first_name.text, last_name.text, date_of_birth.date, gender.text, address.text, phone_number.text, email.text, emergency_contact_name.text, emergency_contact_phone.text, created_at.timestamp, updated_at.timestamp ) ##Table Structure CREATE TABLE government_services.services ( service_id text PRIMARY KEY, agency_id text, service_name text, description text, category text, eligibility_criteria text, standard_fee numeric, average_processing_time_days int, is_active boolean, online_application_url text ) CREATE TABLE government_services.service_locations ( location_id text PRIMARY KEY, agency_id text, location_name text, address text, city text, state text, postal_code text, latitude numeric, longitude numeric, operating_hours text, contact_phone text, is_accessible boolean ) 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) ) ##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 ) ##Table Structure CREATE TABLE insurance.claims ( claim_id text PRIMARY KEY, policy_id text, customer_id text, incident_date timestamp, reported_date timestamp, description text, estimated_loss numeric, status text, settlement_amount numeric, settlement_date date, claim_handler_id text, police_report_number text ) 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 ) CREATE TABLE insurance.agents ( agent_id text PRIMARY KEY, first_name text, last_name text, agency_name text, license_number text, license_state text, contact_email text, contact_phone text, hire_date date, termination_date date, status text, commission_rate numeric, manager_id text ) ##Table Structure CREATE TABLE smart_money_token_inflow ( token_address character varying(100) NOT NULL, -- the token's address token_symbol character varying(100), -- the tokens's symbol token_amount numeric(38,2), -- the absolute value of the amount if user bought minus the amount user sold of this token usd_value numeric(38,2), -- the absolute usd value of the bought token minus sold token avg_price numeric(38,6), -- the average cost price of user spent on this token type int, -- the direction of the trade on this token. 1 means buying, 2 means selling address_amount integer, -- the amount of the user bought this token narrative character varying(100), -- the category or narrative of the token chain character varying(100), -- the chain that the token resides ,PRIMARY KEY (token_address, chain) ) ##Table Structure 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 )
[ { "role": "user", "content": "Show me all vehicles that are due for their next service before the end of this month, along with their last service date and type." }, { "role": "assistant", "content": "SELECT v.vehicle_id, v.make, v.model, s.service_date, s.service_type FROM transportation.vehicl...
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 gaming_technology.game_sessions ( session_id uuid NOT NULL DEFAULT gen_random_uuid(), -- unique identifier for the game session player_id uuid NOT NULL, -- FK linking to the players table game_id uuid NOT NULL, -- FK linking to the games table server_id uuid, -- FK linking to the servers table (nullable for single-player) start_time timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the session began end_time timestamp with time zone, -- when the session ended (null if ongoing) duration_seconds integer, -- calculated duration of the session in seconds score integer, -- player's score for the session, if applicable session_data jsonb, -- flexible field for session-specific info (e.g., map played, character used) PRIMARY KEY (session_id) -- FOREIGN KEY (player_id) REFERENCES gaming_technology.players(player_id), -- FOREIGN KEY (game_id) REFERENCES gaming_technology.games(game_id), -- FOREIGN KEY (server_id) REFERENCES gaming_technology.servers(server_id) ) ##Table Structure CREATE TABLE gaming_technology.players ( player_id uuid PRIMARY KEY, username text, email text, password_hash text, registration_date timestamptz, last_login timestamptz, country_code text, status text, profile_data jsonb ) CREATE TABLE gaming_technology.games ( game_id uuid PRIMARY KEY, title text, developer_id uuid, publisher_id uuid, genre text, release_date date, description text, platform text, engine text, website text ) CREATE TABLE gaming_technology.servers ( server_id uuid PRIMARY KEY, game_id uuid, server_name text, region text, ip_address text, port int, current_players int, max_players int, status text, last_heartbeat timestamptz ) CREATE TABLE gaming_technology.achievements ( achievement_id uuid PRIMARY KEY, game_id uuid, name text, description text, icon_url text, points int, hidden boolean ) CREATE TABLE gaming_technology.player_achievements ( player_achievement_id uuid PRIMARY KEY, player_id uuid, achievement_id uuid, unlocked_at timestamptz ) CREATE TABLE gaming_technology.in_game_items ( item_id uuid PRIMARY KEY, game_id uuid, item_name text, item_type text, description text, rarity text, cost_currency text, cost_amount numeric, attributes jsonb ) CREATE TABLE gaming_technology.player_inventory ( inventory_id uuid PRIMARY KEY, player_id uuid, item_id uuid, quantity int, acquired_at timestamptz, instance_data jsonb ) ##Table Structure CREATE TABLE transportation.vehicles ( vehicle_id text PRIMARY KEY, license_plate text, vin text, make text, model text, year int, type text, capacity int, fuel_type text, status text, depot_id text, acquisition_date date ) CREATE TABLE transportation.locations ( location_id text, name text, type text, address_line1 text, city text, state_province text, postal_code text, country text, latitude numeric, longitude numeric, timezone text ) CREATE TABLE transportation.passengers ( passenger_id character varying(64) NOT NULL, -- unique identifier for the passenger first_name character varying(128) NOT NULL, -- passenger's first name last_name character varying(128) NOT NULL, -- passenger's last name email character varying(128) UNIQUE, -- email address phone_number character varying(32) UNIQUE, -- phone number date_of_birth date, -- passenger's date of birth loyalty_program_id character varying(64), -- identifier for loyalty program membership created_at timestamp with time zone NOT NULL, -- time when the passenger record was created 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) ) ##Table Structure CREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, 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 int, num_children int, status text, booking_source text, rate_plan_id text, total_amount numeric, amount_paid numeric, special_requests text, created_at timestamp, updated_at timestamp )
[ { "role": "user", "content": "Find the date (calendar day) with the highest total number of game sessions. Show the date and the total session count." }, { "role": "assistant", "content": "SELECT CAST(start_time AS DATE) AS session_date, COUNT(*) AS total_sessions\nFROM gaming_technology.game_se...
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 character varying(64) NOT NULL, -- unique identifier for the property (hotel, resort, etc.) property_name character varying(255) NOT NULL, -- name of the property address_line1 character varying(255) NOT NULL, -- primary address line address_line2 character varying(255), -- secondary address line city character varying(100) NOT NULL, -- city state_province character varying(100), -- state or province postal_code character varying(20) NOT NULL, -- zip or postal code country_code character varying(3) NOT NULL, -- ISO country code (e.g., USA, CAN) phone_number character varying(30), -- main contact phone email_address character varying(255), -- main contact email property_type character varying(50) NOT NULL, -- e.g., Hotel, Resort, B&B, Motel star_rating numeric(2,1), -- star rating (e.g., 4.5) timezone character varying(64) NOT NULL, -- IANA timezone ID (e.g., America/New_York) manager_staff_id character varying(64), -- FK to staff table for the general manager 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 (property_id) ) 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 PRIMARY KEY, property_id text, type_name text, description text, base_rate numeric, max_occupancy int, bed_type text, area_sqft numeric, amenities text ) CREATE TABLE hospitality_technology.guests ( guest_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, email character varying(255) UNIQUE, phone_number character varying(30), date_of_birth date, address_line1 character varying(255), city character varying(100), state_province character varying(100), postal_code character varying(20), country_code character varying(3), preferences text, loyalty_member_id character varying(64) UNIQUE, communication_consent boolean DEFAULT true, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (guest_id) ) CREATE TABLE hospitality_technology.reservations ( reservation_id text PRIMARY KEY, 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 int, num_children int, 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.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 PRIMARY KEY, reservation_id text, guest_id text, service_id text, staff_id_ordered text, staff_id_delivered text, order_timestamp timestamp, delivery_timestamp timestamp, quantity int, unit_price numeric, total_price numeric, status text, notes text, bill_id text ) CREATE TABLE hospitality_technology.payments ( payment_id text, reservation_id text, guest_id text, bill_id text, amount numeric, currency_code text, payment_method text, card_type text, card_last_four text, transaction_ref text, payment_timestamp timestamp, status text, staff_id_processed text, notes 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 ) ##Table Structure CREATE TABLE insurance.premium_payments ( payment_id character varying(64) NOT NULL, -- unique identifier for the payment policy_id character varying(64) NOT NULL, -- identifier of the policy the payment is for (FK to policies) customer_id character varying(64) NOT NULL, -- identifier of the customer making the payment (FK to customers) payment_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- date the payment was received amount_paid numeric(12, 2) NOT NULL, -- amount of the payment payment_method character varying(50), -- e.g., Credit Card, Bank Transfer, Check transaction_reference character varying(128) UNIQUE, -- reference from payment processor due_date date, -- due date for this payment installment payment_period_start date, -- start date of the period this payment covers payment_period_end date, -- end date of the period this payment covers status character varying(30) NOT NULL DEFAULT 'Completed', -- e.g., Completed, Pending, Failed, Refunded PRIMARY KEY (payment_id) ) ##Table Structure CREATE TABLE social_media.comments ( comment_id character varying(64) NOT NULL, -- unique identifier for the comment post_id character varying(64) NOT NULL, -- identifier of the post being commented on (FK to posts.post_id) user_id character varying(64) NOT NULL, -- identifier of the user who made the comment (FK to users.user_id) parent_comment_id character varying(64), -- identifier of the parent comment if it's a reply (FK to comments.comment_id) content text NOT NULL, -- textual content of the comment created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of comment creation updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- timestamp of last comment edit PRIMARY KEY (comment_id) ) ##Table Structure CREATE TABLE web3.events ( event_id.text, contract_id.text, event_name.text, data.text, emitted_at.timestamp, transaction_id.text, log_index.integer ) CREATE TABLE web3.transactions ( transaction_id character varying(64) NOT NULL, from_address character varying(128) NOT NULL, to_address character varying(128), value numeric(38,14) NOT NULL, gas_used integer NOT NULL, gas_price numeric(38,14) NOT NULL, block_number integer NOT NULL, timestamp timestamp NOT NULL, input_data text, status character varying(32) NOT NULL, nonce integer NOT NULL, PRIMARY KEY (transaction_id) ) CREATE TABLE web3.tokens ( token_id.text, contract_address.text, token_name.text, token_symbol.text, decimals.integer, total_supply.numeric ) CREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp ) CREATE TABLE web3.users ( user_id text PRIMARY KEY, username text, email text, password_hash text, created_at timestamp )
[ { "role": "user", "content": "List property names and the total maximum occupancy across all their room types." }, { "role": "assistant", "content": "SELECT T1.property_name, SUM(T2.max_occupancy) FROM properties AS T1 JOIN room_types AS T2 ON T1.property_id = T2.property_id GROUP BY T1.property...
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, -- unique identifier for the client first_name character varying(100) NOT NULL, -- client's first name last_name character varying(100) NOT NULL, -- client's last name company_name character varying(200), -- company name if applicable email character varying(128) UNIQUE NOT NULL, -- client's primary email phone character varying(32), -- client's contact phone number address text, -- client's full address date_registered timestamp NOT NULL, -- when the client was first registered status character varying(32) NOT NULL, -- client status (e.g., active, inactive, prospect) PRIMARY KEY (client_id) ) CREATE TABLE legal_services.law_firms ( firm_id character varying(64) NOT NULL, -- unique identifier for the law firm firm_name character varying(200) NOT NULL, -- official name of the law firm address text NOT NULL, -- primary address of the firm phone character varying(32), -- firm's main phone number website character varying(255), -- firm's website URL founded_date date, -- date the firm was established managing_partner_id character varying(64), -- FK to lawyers table (optional) PRIMARY KEY (firm_id) ) 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.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) ) CREATE TABLE legal_services.time_entries ( entry_id character varying(64) NOT NULL, -- unique identifier for the time entry case_id character varying(64) NOT NULL, -- FK to cases table lawyer_id character varying(64) NOT NULL, -- FK to lawyers table (who performed the work) date_worked date NOT NULL, -- date the work was performed hours_spent numeric(5, 2) NOT NULL CHECK (hours_spent > 0), -- duration of work in hours (e.g., 1.5 for 1h 30m) billing_rate numeric(10, 2) NOT NULL, -- hourly rate applied for this entry description text NOT NULL, -- detailed description of the work performed is_billable boolean DEFAULT true, -- whether this time entry is billable to the client is_billed boolean DEFAULT false, -- whether this entry has been included in an invoice invoice_id character varying(64), -- FK to invoices table (once billed) created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, -- when the entry was recorded PRIMARY KEY (entry_id) ) CREATE TABLE legal_services.appointments ( appointment_id character varying(64) NOT NULL, -- unique identifier for the appointment client_id character varying(64) NOT NULL, -- FK to clients table lawyer_id character varying(64) NOT NULL, -- FK to lawyers table case_id character varying(64), -- FK to cases table (optional, if related to a specific case) start_time timestamp NOT NULL, -- scheduled start date and time end_time timestamp NOT NULL, -- scheduled end date and time location text, -- location of the meeting (address or virtual link) subject character varying(255), -- subject or purpose of the appointment notes text, -- additional notes for the appointment status character varying(50) NOT NULL, -- e.g., Scheduled, Completed, Canceled, Rescheduled created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (appointment_id) ) ##Table Structure CREATE TABLE web3.users ( user_id text, username text, email text, password_hash text, created_at timestamp ) ##Table Structure CREATE TABLE government_services.applications ( application_id text, citizen_id text, service_id text, submitted_at timestamp, status text, last_updated_at timestamp, assigned_employee_id text, decision_date date, notes text, reference_number text ) CREATE TABLE government_services.notifications ( notification_id text, citizen_id text, application_id text, message_subject text, message_body text, channel text, sent_at timestamp, status text, related_entity_type text, related_entity_id text ) ##Table Structure CREATE TABLE blockchain.wallets ( wallet_id.text, user_id.text, address_id.text, private_key.text ) CREATE TABLE blockchain.users ( user_id.text, username.text, email.text, password_hash.text ) ##Table Structure CREATE TABLE web3.wallets ( wallet_id text, user_id text, address text, private_key text, created_at timestamp )
[ { "role": "user", "content": "Which law firms have handled appointments with clients who registered in 2024? Please provide the law firm name, the client’s first and last name, and the appointment subject." }, { "role": "assistant", "content": "SELECT lf.firm_name, c.first_name, c.last_name, a.s...
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
4