db_id stringclasses 146 values | question stringlengths 3 224 | sql stringlengths 18 577 | database_schema stringclasses 146 values |
|---|---|---|---|
customers_card_transactions | What are card ids, customer ids, card types, and card numbers for each customer card? | SELECT card_id , customer_id , card_type_code , card_number FROM Customers_cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the date valid from and the date valid to for the card with card number '4560596484842'. | SELECT date_valid_from , date_valid_to FROM Customers_cards WHERE card_number = "4560596484842" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the valid from and valid to dates for the card with the number 4560596484842? | SELECT date_valid_from , date_valid_to FROM Customers_cards WHERE card_number = "4560596484842" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the first name, last name, and phone of the customer with card 4560596484842. | SELECT T2.customer_first_name , T2.customer_last_name , T2.customer_phone FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.card_number = "4560596484842" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the full name and phone of the customer who has card number 4560596484842. | SELECT T2.customer_first_name , T2.customer_last_name , T2.customer_phone FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.card_number = "4560596484842" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many cards does customer Art Turcotte have? | SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Count the number of cards the customer with the first name Art and last name Turcotte has. | SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Art" AND T2.customer_last_name = "Turcotte" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many debit cards do we have? | SELECT count(*) FROM Customers_cards WHERE card_type_code = "Debit" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Count the number of customer cards of the type Debit. | SELECT count(*) FROM Customers_cards WHERE card_type_code = "Debit" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many credit cards does customer Blanche Huels have? | SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Blanche" AND T2.customer_last_name = "Huels" AND T1.card_type_code = "Credit" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Count the number of credit cards that the customer with first name Blanche and last name Huels has. | SELECT count(*) FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = "Blanche" AND T2.customer_last_name = "Huels" AND T1.card_type_code = "Credit" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show all customer ids and the number of cards owned by each customer. | SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different customer ids, and how many cards does each one hold? | SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the customer id with most number of cards, and how many does he have? | SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the id of the customer who has the most cards, as well as the number of cards. | SELECT customer_id , count(*) FROM Customers_cards GROUP BY customer_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show id, first and last names for all customers with at least two cards. | SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 2 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the ids and full names of customers who hold two or more cards? | SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id HAVING count(*) >= 2 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the customer id, first and last name with least number of accounts. | SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) ASC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the id and full name of the customer who has the fewest accounts. | SELECT T1.customer_id , T2.customer_first_name , T2.customer_last_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) ASC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show all card type codes and the number of cards in each type. | SELECT card_type_code , count(*) FROM Customers_cards GROUP BY card_type_code | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different card types, and how many cards are there of each? | SELECT card_type_code , count(*) FROM Customers_cards GROUP BY card_type_code | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the card type code with most number of cards? | SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the code of the card type that is most common. | SELECT card_type_code FROM Customers_cards GROUP BY card_type_code ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show card type codes with at least 5 cards. | SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING count(*) >= 5 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the codes of card types that have 5 or more cards? | SELECT card_type_code FROM Customers_cards GROUP BY card_type_code HAVING count(*) >= 5 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show all card type codes and the number of customers holding cards in each type. | SELECT card_type_code , count(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different card type codes, and how many different customers hold each type? | SELECT card_type_code , count(DISTINCT customer_id) FROM Customers_cards GROUP BY card_type_code | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the customer ids and firstname without a credit card. | SELECT customer_id , customer_first_name FROM Customers EXCEPT SELECT T1.customer_id , T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = "Credit" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the ids and first names of customers who do not hold a credit card? | SELECT customer_id , customer_first_name FROM Customers EXCEPT SELECT T1.customer_id , T2.customer_first_name FROM Customers_cards AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE card_type_code = "Credit" | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show all card type codes. | SELECT DISTINCT card_type_code FROM Customers_Cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different card type codes? | SELECT DISTINCT card_type_code FROM Customers_Cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the number of card types. | SELECT count(DISTINCT card_type_code) FROM Customers_Cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many different card types are there? | SELECT count(DISTINCT card_type_code) FROM Customers_Cards | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show all transaction types. | SELECT DISTINCT transaction_type FROM Financial_Transactions | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different types of transactions? | SELECT DISTINCT transaction_type FROM Financial_Transactions | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the number of transaction types. | SELECT count(DISTINCT transaction_type) FROM Financial_Transactions | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | How many different types of transactions are there? | SELECT count(DISTINCT transaction_type) FROM Financial_Transactions | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the average and total transaction amount? | SELECT avg(transaction_amount) , sum(transaction_amount) FROM Financial_transactions | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the average transaction amount, as well as the total amount of all transactions. | SELECT avg(transaction_amount) , sum(transaction_amount) FROM Financial_transactions | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the card type codes and the number of transactions. | SELECT T2.card_type_code , count(*) FROM Financial_transactions AS T1 JOIN Customers_cards AS T2 ON T1.card_id = T2.card_id GROUP BY T2.card_type_code | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different card types, and how many transactions have been made with each? | SELECT T2.card_type_code , count(*) FROM Financial_transactions AS T1 JOIN Customers_cards AS T2 ON T1.card_id = T2.card_id GROUP BY T2.card_type_code | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the transaction type and the number of transactions. | SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different transaction types, and how many transactions of each have taken place? | SELECT transaction_type , count(*) FROM Financial_transactions GROUP BY transaction_type | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What is the transaction type that has processed the greatest total amount in transactions? | SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY sum(transaction_amount) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Return the type of transaction with the highest total amount. | SELECT transaction_type FROM Financial_transactions GROUP BY transaction_type ORDER BY sum(transaction_amount) DESC LIMIT 1 | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | Show the account id and the number of transactions for each account | SELECT account_id , count(*) FROM Financial_transactions GROUP BY account_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
customers_card_transactions | What are the different account ids that have made financial transactions, as well as how many transactions correspond to each? | SELECT account_id , count(*) FROM Financial_transactions GROUP BY account_id | CREATE TABLE `Accounts` (
`account_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`account_name` VARCHAR(50),
`other_account_details` VARCHAR(255)
)
3 rows from Accounts table:
account_id customer_id account_name other_account_details
1 6 338 Regular
2 14 562 VIP
3 9 162 VIP
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_first_name` VARCHAR(20),
`customer_last_name` VARCHAR(20),
`customer_address` VARCHAR(255),
`customer_phone` VARCHAR(255),
`customer_email` VARCHAR(255),
`other_customer_details` VARCHAR(255)
)
3 rows from Customers table:
customer_id customer_first_name customer_last_name customer_address customer_phone customer_email other_customer_details
1 Aniyah Feest 55975 Theodore Estates\nLake Brody, VT 57078 (673)872-5338 fahey.dorian@example.com None
2 Susie Wiza 6478 Moen Isle Suite 910\nSchimmelmouth, VT 96364-4898 679-845-8645x94312 idickinson@example.com None
3 Marcel Brekke 1965 Abernathy Plains\nPort Lilla, LA 44867 1-511-656-6664 nichole.rodriguez@example.com None
CREATE TABLE `Customers_Cards` (
`card_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`card_type_code` VARCHAR(15) NOT NULL,
`card_number` VARCHAR(80),
`date_valid_from` DATETIME,
`date_valid_to` DATETIME,
`other_card_details` VARCHAR(255)
)
3 rows from Customers_Cards table:
card_id customer_id card_type_code card_number date_valid_from date_valid_to other_card_details
1 14 Credit 4560596484842 2011-04-17 09:05:28 2018-03-07 17:06:19 5567915676420343
2 9 Credit 4859448397570735 2012-05-22 02:05:41 2018-02-25 15:43:32 4539333582760
3 6 Debit 348237249146948 2014-08-01 14:26:45 2018-03-24 15:29:00 4916210554814
CREATE TABLE `Financial_Transactions` (
`transaction_id` INTEGER NOT NULL ,
`previous_transaction_id` INTEGER,
`account_id` INTEGER NOT NULL,
`card_id` INTEGER NOT NULL,
`transaction_type` VARCHAR(15) NOT NULL,
`transaction_date` DATETIME,
`transaction_amount` DOUBLE NULL,
`transaction_comment` VARCHAR(255),
`other_transaction_details` VARCHAR(255),
FOREIGN KEY (`card_id` ) REFERENCES `Customers_Cards`(`card_id` ),
FOREIGN KEY (`account_id` ) REFERENCES `Accounts`(`account_id` )
)
3 rows from Financial_Transactions table:
transaction_id previous_transaction_id account_id card_id transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 925 15 1 Payment 2018-03-24 06:41:41 1701.23 None None
2 494 3 2 Refund 2018-03-24 12:08:55 1931.76 None None
3 642 4 3 Payment 2018-03-24 09:08:27 486.56 None None
|
race_track | How many tracks do we have? | SELECT count(*) FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Count the number of tracks. | SELECT count(*) FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show the name and location for all tracks. | SELECT name , LOCATION FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names and locations of all tracks? | SELECT name , LOCATION FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show names and seatings, ordered by seating for all tracks opened after 2000. | SELECT name , seating FROM track WHERE year_opened > 2000 ORDER BY seating | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names and seatings for all tracks opened after 2000, ordered by seating? | SELECT name , seating FROM track WHERE year_opened > 2000 ORDER BY seating | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What is the name, location and seating for the most recently opened track? | SELECT name , LOCATION , seating FROM track ORDER BY year_opened DESC LIMIT 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Return the name, location, and seating of the track that was opened in the most recent year. | SELECT name , LOCATION , seating FROM track ORDER BY year_opened DESC LIMIT 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What is the minimum, maximum, and average seating for all tracks. | SELECT min(seating) , max(seating) , avg(seating) FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Return the minimum, maximum, and average seating across all tracks. | SELECT min(seating) , max(seating) , avg(seating) FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show the name, location, open year for all tracks with a seating higher than the average. | SELECT name , LOCATION , year_opened FROM track WHERE seating > (SELECT avg(seating) FROM track) | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names, locations, and years of opening for tracks with seating higher than average? | SELECT name , LOCATION , year_opened FROM track WHERE seating > (SELECT avg(seating) FROM track) | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are distinct locations where tracks are located? | SELECT DISTINCT LOCATION FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Give the different locations of tracks. | SELECT DISTINCT LOCATION FROM track | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | How many races are there? | SELECT count(*) FROM race | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Count the number of races. | SELECT count(*) FROM race | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the distinct classes that races can have? | SELECT DISTINCT CLASS FROM race | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Return the different classes of races. | SELECT DISTINCT CLASS FROM race | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show name, class, and date for all races. | SELECT name , CLASS , date FROM race | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names, classes, and dates for all races? | SELECT name , CLASS , date FROM race | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show the race class and number of races in each class. | SELECT CLASS , count(*) FROM race GROUP BY CLASS | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the different classes of races, and how many races correspond to each? | SELECT CLASS , count(*) FROM race GROUP BY CLASS | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What is the race class with most number of races. | SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Give the class of races that is most common. | SELECT CLASS FROM race GROUP BY CLASS ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | List the race class with at least two races. | SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the classes of races that have two or more corresponding races? | SELECT CLASS FROM race GROUP BY CLASS HAVING count(*) >= 2 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names for tracks without a race in class 'GT'. | SELECT name FROM track EXCEPT SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id WHERE T1.class = 'GT' | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Give the names of tracks that do not have a race in the class 'GT'. | SELECT name FROM track EXCEPT SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id WHERE T1.class = 'GT' | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show all track names that have had no races. | SELECT name FROM track WHERE track_id NOT IN (SELECT track_id FROM race) | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Return the names of tracks that have no had any races. | SELECT name FROM track WHERE track_id NOT IN (SELECT track_id FROM race) | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show year where a track with a seating at least 5000 opened and a track with seating no more than 4000 opened. | SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the years of opening for tracks with seating between 4000 and 5000? | SELECT year_opened FROM track WHERE seating BETWEEN 4000 AND 5000 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show the name of track and the number of races in each track. | SELECT T2.name , count(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names of different tracks, and how many races has each had? | SELECT T2.name , count(*) FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show the name of track with most number of races. | SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What is the name of the track that has had the greatest number of races? | SELECT T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show the name and date for each race and its track name. | SELECT T1.name , T1.date , T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names and dates of races, and the names of the tracks where they are held? | SELECT T1.name , T1.date , T2.name FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Show the name and location of track with 1 race. | SELECT T2.name , T2.location FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id HAVING count(*) = 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the names and locations of tracks that have had exactly 1 race? | SELECT T2.name , T2.location FROM race AS T1 JOIN track AS T2 ON T1.track_id = T2.track_id GROUP BY T1.track_id HAVING count(*) = 1 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | Find the locations where have both tracks with more than 90000 seats and tracks with less than 70000 seats. | SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
race_track | What are the locations that have both tracks with more than 90000 seats, and tracks with fewer than 70000 seats? | SELECT LOCATION FROM track WHERE seating > 90000 INTERSECT SELECT LOCATION FROM track WHERE seating < 70000 | CREATE TABLE "race" (
"Race_ID" int,
"Name" text,
"Class" text,
"Date" text,
"Track_ID" text,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY ("Track_ID") REFERENCES "track"("Track_ID")
)
3 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
3 Mexico City 250 DP/GT April 19 2
CREATE TABLE "track" (
"Track_ID" int,
"Name" text,
"Location" text,
"Seating" real,
"Year_Opened" real,
PRIMARY KEY ("Track_ID")
)
3 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
3 Darlington Raceway Darlington, SC 63000.0 1950.0
|
coffee_shop | How many members have the black membership card? | SELECT count(*) FROM member WHERE Membership_card = 'Black' | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Find the number of members living in each address. | SELECT count(*) , address FROM member GROUP BY address | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Give me the names of members whose address is in Harford or Waterbury. | SELECT name FROM member WHERE address = 'Harford' OR address = 'Waterbury' | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Find the ids and names of members who are under age 30 or with black membership card. | SELECT name , member_id FROM member WHERE Membership_card = 'Black' OR age < 30 | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Find the purchase time, age and address of each member, and show the results in the order of purchase time. | SELECT Time_of_purchase , age , address FROM member ORDER BY Time_of_purchase | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Which membership card has more than 5 members? | SELECT Membership_card FROM member GROUP BY Membership_card HAVING count(*) > 5 | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Which address has both members younger than 30 and members older than 40? | SELECT address FROM member WHERE age < 30 INTERSECT SELECT address FROM member WHERE age > 40 | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | What is the membership card held by both members living in Hartford and ones living in Waterbury address? | SELECT membership_card FROM member WHERE address = 'Hartford' INTERSECT SELECT membership_card FROM member WHERE address = 'Waterbury' | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | How many members are not living in Hartford? | SELECT count(*) FROM member WHERE address != 'Hartford' | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Which address do not have any member with the black membership card? | SELECT address FROM member EXCEPT SELECT address FROM member WHERE Membership_card = 'Black' | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
coffee_shop | Show the shop addresses ordered by their opening year. | SELECT address FROM shop ORDER BY open_year | CREATE TABLE "shop" (
"Shop_ID" int,
"Address" text,
"Num_of_staff" text,
"Score" real,
"Open_Year" text,
PRIMARY KEY ("Shop_ID")
)
3 rows from shop table:
Shop_ID Address Num_of_staff Score Open_Year
1 1200 Main Street 13 42.0 2010
2 1111 Main Street 19 38.0 2008
3 1330 Baltimore Street 42 36.0 2010
CREATE TABLE "member" (
"Member_ID" int,
"Name" text,
"Membership_card" text,
"Age" int,
"Time_of_purchase" int,
"Level_of_membership" int,
"Address" text,
PRIMARY KEY ("Member_ID")
)
3 rows from member table:
Member_ID Name Membership_card Age Time_of_purchase Level_of_membership Address
1 Ashby, Lazale Black 29 18 5 Hartford
2 Breton, Robert White 67 41 4 Waterbury
3 Campbell, Jessie Black 34 20 6 Hartford
CREATE TABLE "happy_hour" (
"HH_ID" int,
"Shop_ID" int,
"Month" text,
"Num_of_shaff_in_charge" int,
PRIMARY KEY ("HH_ID","Shop_ID","Month"),
FOREIGN KEY ("Shop_ID") REFERENCES `shop`("Shop_ID")
)
3 rows from happy_hour table:
HH_ID Shop_ID Month Num_of_shaff_in_charge
1 1 May 10
2 1 April 12
3 10 June 15
CREATE TABLE "happy_hour_member" (
"HH_ID" int,
"Member_ID" int,
"Total_amount" real,
PRIMARY KEY ("HH_ID","Member_ID"),
FOREIGN KEY ("Member_ID") REFERENCES `member`("Member_ID")
)
3 rows from happy_hour_member table:
HH_ID Member_ID Total_amount
1 3 20.90
4 3 20.92
7 9 4.90
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.