db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
db_schema_T
stringlengths
79
5k
db_schema
stringclasses
69 values
difficulty
stringclasses
1 value
question_id
int64
0
9.43k
__index_level_0__
int64
0
9.43k
db_schema_TC
stringlengths
41
1.68k
sql_constructs
listlengths
2
17
sql_complexity
int64
2
46
sql_complexity_buckets
stringclasses
3 values
few_shots
dict
synthea
How many interactions did Lorri Simons have with medical professionals between 2010 and 2017? What percentage of encounters are attributed to prenatal visits?
between 2010 and 2017 refers to substr(encounters.DATE, 1, 4) between '2010' and '2017'; percentage = MULTIPLY(DIVIDE(COUNT(encounters.ID WHERE DESCRIPTION = 'Prenatal visit'), count(encounters.ID)), 1.0); prenatal visits refers to encounters.DESCRIPTION = 'Prenatal visit';
SELECT COUNT(T1.patient) , CAST(SUM(CASE WHEN T2.DESCRIPTION = 'Prenatal visit' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.patient) FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Lorri' AND T1.last = 'Simonis' AND strftime('%Y', T2.DATE) BETWEEN '2010' AND '2017'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,501
1,501
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `encounters` ( DATE DATE, PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key PATIENT references patientspatient )
[ "CASE WHEN", "AS", "AND", "SELECT", "SUM", "strftime", "CASE", "INNER JOIN", "ON", "CAST", "COUNT", "BETWEEN", "FROM" ]
18
challenging
{ "case_1": [ -1 ], "case_2": [ 581 ], "case_3": [ 30, 53, 374, 433, 516, 519, 544, 581, 628, 760, 923, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 4, 6, 16, 22, 24, 30, 37, 39, 42, 47, 51, 53, 61, 63, 64, 68, 69, 71, 73, 74, 75, 76, 77, 81, 85, 88, 93, 96, 98, 106, 112, 113, 115, 117, 118, 119, 120, 125, 127, 129, 131, 141, 142, 143, 146, 148, 152, 153, 155, 158, 160, 164, 169, 170, 173, 175, 183, 184, 187, 189, 191, 192, 195, 197, 201, 207, 212, 214, 215, 219, 223, 225, 226, 227, 234, 236, 244, 248, 254, 256, 258, 261, 264, 267, 268, 271, 276, 277, 278, 279, 296, 299, 300, 301, 304, 314, 316, 317, 319, 322, 323, 325, 330, 335, 339, 341, 347, 356, 360, 370, 374, 375, 382, 383, 391, 393, 398, 402, 403, 406, 409, 412, 414, 415, 416, 417, 423, 424, 426, 427, 433, 436, 438, 444, 448, 451, 452, 453, 458, 463, 464, 469, 470, 476, 477, 478, 482, 483, 485, 486, 487, 488, 490, 493, 500, 504, 510, 514, 515, 516, 517, 518, 519, 520, 526, 528, 530, 535, 537, 540, 544, 547, 550, 558, 559, 560, 562, 563, 564, 571, 573, 575, 580, 581, 582, 595, 597, 608, 612, 613, 620, 623, 627, 628, 630, 632, 633, 640, 641, 646, 658, 662, 663, 666, 668, 671, 676, 677, 681, 682, 683, 686, 687, 690, 710, 712, 714, 723, 727, 734, 735, 739, 740, 743, 744, 747, 749, 750, 753, 756, 760, 762, 767, 768, 772, 776, 777, 787, 788, 795, 796, 797, 798, 799, 800, 802, 804, 808, 810, 813, 814, 819, 824, 825, 827, 830, 832, 838, 841, 844, 848, 849, 851, 853, 867, 868, 870, 871, 874, 877, 886, 888, 894, 896, 898, 902, 909, 912, 917, 922, 923, 924, 926, 930, 935, 943, 944, 954, 956, 958, 959, 961, 969, 985, 986, 996, 998, 1008, 1012, 1022, 1023, 1027, 1031, 1042, 1058, 1062, 1064, 1067, 1068, 1069, 1071, 1072, 1078, 1082, 1084, 1086, 1087, 1092, 1098, 1100, 1101, 1103, 1104, 1119, 1121, 1123, 1128, 1131, 1133, 1134, 1135 ] }
synthea
State description of medication taken by Joe Homenick.
description of medication refers to medications.DESCRIPTION;
SELECT T1.DESCRIPTION FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Joye' AND T2.last = 'Homenick'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,502
1,502
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `medications` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ -1 ], "case_2": [ 53, 433, 693 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
What is the start date of the care plan of the patient whose maiden name is Adams?
start date of the care plan refers to careplans.START;
SELECT DISTINCT T1.START FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.maiden = 'Adams'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,503
1,503
CREATE TABLE `patients` ( patient TEXT primary key, maiden TEXT ) CREATE TABLE `careplans` ( ID TEXT, START DATE, PATIENT TEXT, foreign key ENCOUNTER references encountersID, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Among the male patients, who has the earliest starting date of the care plan?
male patients refers to gender = 'M'; earliest starting date of the care plan refers to MIN(careplans.START);
SELECT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.gender = 'M' ORDER BY T1.START LIMIT 1
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,504
1,504
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT, gender TEXT ) CREATE TABLE `careplans` ( START DATE, PATIENT TEXT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 208, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 252, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 285, 286, 287, 289, 290, 291, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 352, 353, 354, 356, 357, 358, 359, 360, 361, 363, 364, 365, 368, 369, 370, 371, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 619, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 664, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 710, 711, 712, 713, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 836, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 869, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 946, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 972, 973, 974, 975, 977, 980, 981, 983, 985, 986, 987, 988, 989, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1024, 1025, 1027, 1029, 1030, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1057, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1075, 1076, 1077, 1078, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1139, 1141 ] }
synthea
What is the percentage of Hispanic patients who stopped their care plan in 2011?
Hispanic patients refers to ethnicity = 'hispanic'; percentage = MULTIPLY(DIVIDE(COUNT(careplans.PATIENT WHERE ethnicity = 'hispanic'), COUNT(careplans.PATIENT)), 1.0); stopped their care plan in 2011 refers to substr(careplans.stop, 1, 4) = '2011';
SELECT CAST(SUM(CASE WHEN T2.race = 'hispanic' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.PATIENT) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE strftime('%Y', T1.stop) = '2011'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,505
1,505
CREATE TABLE `patients` ( patient TEXT primary key, race TEXT ) CREATE TABLE `careplans` ( STOP DATE, PATIENT TEXT, foreign key PATIENT references patientspatient )
[ "CASE WHEN", "AS", "SELECT", "SUM", "strftime", "CASE", "INNER JOIN", "ON", "CAST", "COUNT", "FROM" ]
13
medium
{ "case_1": [ -1 ], "case_2": [ 30 ], "case_3": [ 30, 53, 374, 433, 516, 519, 544, 581, 628, 760, 923, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 4, 6, 11, 16, 22, 24, 27, 30, 35, 36, 37, 39, 42, 47, 51, 53, 55, 61, 62, 63, 64, 68, 69, 71, 73, 74, 75, 77, 81, 82, 83, 85, 86, 87, 88, 91, 93, 94, 96, 98, 104, 106, 112, 113, 115, 117, 118, 119, 120, 121, 125, 126, 127, 129, 131, 140, 141, 142, 143, 146, 148, 152, 153, 155, 158, 159, 160, 164, 167, 169, 170, 171, 173, 175, 179, 183, 184, 186, 187, 188, 189, 190, 191, 192, 195, 196, 197, 199, 201, 202, 206, 207, 212, 213, 214, 215, 219, 223, 225, 226, 227, 228, 229, 233, 234, 236, 243, 244, 247, 248, 254, 256, 258, 261, 264, 267, 268, 269, 271, 276, 277, 278, 279, 296, 298, 299, 300, 301, 304, 311, 313, 314, 316, 317, 319, 320, 322, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 347, 349, 354, 356, 358, 360, 363, 364, 365, 370, 373, 374, 375, 378, 379, 381, 382, 383, 384, 391, 392, 393, 394, 398, 401, 402, 403, 406, 409, 411, 412, 414, 415, 416, 417, 423, 424, 426, 427, 433, 436, 438, 444, 445, 448, 450, 451, 452, 453, 454, 458, 460, 462, 464, 465, 467, 469, 470, 471, 473, 476, 477, 478, 479, 483, 484, 485, 486, 487, 488, 490, 493, 500, 504, 505, 509, 510, 514, 515, 516, 517, 518, 519, 520, 526, 528, 532, 535, 536, 537, 538, 540, 544, 547, 548, 550, 552, 558, 559, 560, 563, 564, 566, 571, 573, 575, 579, 580, 581, 582, 595, 596, 597, 606, 608, 609, 611, 612, 613, 620, 623, 627, 628, 630, 632, 633, 634, 638, 640, 641, 645, 646, 649, 650, 654, 658, 659, 662, 663, 665, 666, 668, 669, 671, 672, 676, 681, 682, 683, 686, 687, 688, 690, 694, 695, 696, 701, 705, 706, 710, 712, 714, 717, 721, 723, 727, 733, 734, 735, 736, 739, 740, 743, 744, 745, 747, 749, 750, 752, 753, 756, 760, 762, 767, 768, 769, 772, 776, 777, 778, 779, 787, 788, 790, 795, 796, 797, 798, 799, 800, 802, 804, 805, 808, 810, 812, 813, 814, 818, 819, 823, 824, 825, 827, 830, 832, 838, 839, 841, 844, 848, 849, 851, 853, 857, 866, 867, 868, 870, 871, 874, 876, 877, 880, 886, 888, 893, 894, 896, 897, 898, 901, 902, 909, 911, 912, 913, 915, 917, 918, 922, 923, 924, 926, 927, 930, 934, 935, 941, 943, 944, 950, 951, 954, 956, 958, 959, 961, 962, 963, 969, 973, 975, 977, 981, 985, 986, 993, 996, 998, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1022, 1023, 1027, 1031, 1037, 1038, 1042, 1043, 1047, 1050, 1051, 1058, 1062, 1064, 1066, 1067, 1068, 1069, 1071, 1072, 1078, 1082, 1084, 1086, 1087, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1106, 1112, 1119, 1121, 1123, 1124, 1128, 1131, 1133, 1134, 1135, 1137 ] }
synthea
State the description of the reason why Angelo Buckridge needs the care plan.
description of the reason of the care plan refers to careplans.REASONDESCRIPTION;
SELECT DISTINCT T1.REASONDESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Angelo' AND T2.last = 'Buckridge'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,506
1,506
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Mention the description of the care plan of American patients.
American refers to ethnicity = 'american';
SELECT DISTINCT T1.DESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ethnicity = 'american'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,507
1,507
CREATE TABLE `patients` ( patient TEXT primary key, ethnicity TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
What are the medical encounter ids of patients who were born in Pembroke MA US?
medical encounter ids careplans.ID; born in Pembroke MA US refers to birthplace = 'Pembroke MA US';
SELECT DISTINCT T1.ENCOUNTER FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.birthplace = 'Pembroke MA US'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,508
1,508
CREATE TABLE `patients` ( patient TEXT primary key, birthplace TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, ENCOUNTER TEXT, foreign key ENCOUNTER references encountersID, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
List out the start date of the care plan of alive patients.
start of the care plan refers to careplans.START; alive patients refers to deathdate is null;
SELECT DISTINCT T1.START FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NULL
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,509
1,509
CREATE TABLE `patients` ( patient TEXT primary key, deathdate DATE ) CREATE TABLE `careplans` ( START DATE, PATIENT TEXT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "NULL", "INNER JOIN", "ON", "IS", "FROM" ]
8
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 508, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
How many white patients have the reason code of 10509002?
white refers to race = 'white'; reason code of 10509002 refers to careplans.REASONCODE = '10509002';
SELECT COUNT(DISTINCT T1.PATIENT) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.race = 'white' AND T1.REASONCODE = '10509002'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,510
1,510
CREATE TABLE `patients` ( patient TEXT primary key, race TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, CODE REAL, REASONCODE INTEGER, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
8
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 554, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 618, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 692, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 707, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 730, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 820, 822, 823, 824, 825, 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, 838, 839, 841, 843, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 903, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 945, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1079, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1126, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
List out full name of patients who have "Diabetic diet" in the description of the care plan.
full name = first, last; Diabetic diet refers to careplans.DESCRIPTION = 'Diabetic diet';
SELECT DISTINCT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Diabetic diet'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,511
1,511
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
List out the stop date of the care plan of dead patients.
stop date of the care plan refers to careplans.STOP; dead patients refers to deathdate is not null;
SELECT DISTINCT T1.STOP FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NOT NULL AND T1.STOP IS NOT NULL
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,512
1,512
CREATE TABLE `patients` ( patient TEXT primary key, deathdate DATE ) CREATE TABLE `careplans` ( STOP DATE, PATIENT TEXT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "NULL", "INNER JOIN", "ON", "NOT", "IS", "FROM" ]
13
medium
{ "case_1": [ -1 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 508, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1010, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
How many Italian patients have the care plan code of 304510005?
Italian patients refers to ethnicity = 'italian';
SELECT COUNT(DISTINCT T2.patient) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ethnicity = 'italian' AND T1.CODE = '304510005'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,513
1,513
CREATE TABLE `patients` ( patient TEXT primary key, ethnicity TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, CODE REAL, REASONCODE INTEGER, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
8
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 554, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 618, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 692, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 707, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 730, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 820, 822, 823, 824, 825, 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, 838, 839, 841, 843, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 903, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 945, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1079, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1126, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
What is the percentage of female patients who started the care plan in 2010?
female patients refers to gender = 'F'; started the care plan in 2010 refers to substr(careplans.START, 1, 4) = '2010'; percentage = MULTIPLY(DIVIDE(COUNT(patients.patient WHERE patients.gender = 'F'), COUNT(patients.patient) WHERE substr(careplans.START, 1, 4) = '2010'), 100);
SELECT CAST(SUM(CASE WHEN T2.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.PATIENT) AS percentage FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE strftime('%Y', T1.START) = '2010'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,514
1,514
CREATE TABLE `patients` ( patient TEXT primary key, gender TEXT ) CREATE TABLE `careplans` ( START DATE, PATIENT TEXT, foreign key PATIENT references patientspatient )
[ "CASE WHEN", "AS", "SELECT", "SUM", "strftime", "CASE", "INNER JOIN", "ON", "CAST", "COUNT", "FROM" ]
14
medium
{ "case_1": [ -1 ], "case_2": [ 30 ], "case_3": [ 30, 53, 374, 433, 516, 519, 544, 581, 628, 760, 923, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 4, 6, 11, 16, 22, 24, 27, 30, 35, 36, 37, 39, 42, 47, 51, 53, 55, 61, 62, 63, 64, 68, 69, 71, 73, 74, 75, 77, 81, 82, 83, 85, 86, 87, 88, 91, 93, 94, 96, 98, 104, 106, 112, 113, 115, 117, 118, 119, 120, 121, 125, 126, 127, 129, 131, 140, 141, 142, 143, 146, 148, 152, 153, 155, 158, 159, 160, 164, 167, 169, 170, 171, 173, 175, 179, 183, 184, 186, 187, 188, 189, 190, 191, 192, 195, 196, 197, 199, 201, 202, 206, 207, 212, 213, 214, 215, 219, 223, 225, 226, 227, 228, 229, 233, 234, 236, 243, 244, 247, 248, 254, 256, 258, 261, 264, 267, 268, 269, 271, 276, 277, 278, 279, 296, 298, 299, 300, 301, 304, 311, 313, 314, 316, 317, 319, 320, 322, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 347, 349, 354, 356, 358, 360, 363, 364, 365, 370, 373, 374, 375, 378, 379, 381, 382, 383, 384, 391, 392, 393, 394, 398, 401, 402, 403, 406, 409, 411, 412, 414, 415, 416, 417, 423, 424, 426, 427, 433, 436, 438, 444, 445, 448, 450, 451, 452, 453, 454, 458, 460, 462, 464, 465, 467, 469, 470, 471, 473, 476, 477, 478, 479, 483, 484, 485, 486, 487, 488, 490, 493, 500, 504, 505, 509, 510, 514, 515, 516, 517, 518, 519, 520, 526, 528, 532, 535, 536, 537, 538, 540, 544, 547, 548, 550, 552, 558, 559, 560, 563, 564, 566, 571, 573, 575, 579, 580, 581, 582, 595, 596, 597, 606, 608, 609, 611, 612, 613, 620, 623, 627, 628, 630, 632, 633, 634, 638, 640, 641, 645, 646, 649, 650, 654, 658, 659, 662, 663, 665, 666, 668, 669, 671, 672, 676, 681, 682, 683, 686, 687, 688, 690, 694, 695, 696, 701, 705, 706, 710, 712, 714, 717, 721, 723, 727, 733, 734, 735, 736, 739, 740, 743, 744, 745, 747, 749, 750, 752, 753, 756, 760, 762, 767, 768, 769, 772, 776, 777, 778, 779, 787, 788, 790, 795, 796, 797, 798, 799, 800, 802, 804, 805, 808, 810, 812, 813, 814, 818, 819, 823, 824, 825, 827, 830, 832, 838, 839, 841, 844, 848, 849, 851, 853, 857, 866, 867, 868, 870, 871, 874, 876, 877, 880, 886, 888, 893, 894, 896, 897, 898, 901, 902, 909, 911, 912, 913, 915, 917, 918, 922, 923, 924, 926, 927, 930, 934, 935, 941, 943, 944, 950, 951, 954, 956, 958, 959, 961, 962, 963, 969, 973, 975, 977, 981, 985, 986, 993, 996, 998, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1022, 1023, 1027, 1031, 1037, 1038, 1042, 1043, 1047, 1050, 1051, 1058, 1062, 1064, 1066, 1067, 1068, 1069, 1071, 1072, 1078, 1082, 1084, 1086, 1087, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1106, 1112, 1119, 1121, 1123, 1124, 1128, 1131, 1133, 1134, 1135, 1137 ] }
synthea
How many black patients stopped their care plan in 2017?
black refers to race = 'black'; stopped their care plan in 2017 refers to substr(careplans.STOP, 1, 4) = '2017';
SELECT COUNT(DISTINCT T2.patient) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.race = 'black' AND strftime('%Y', T1.STOP) = '2017'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,515
1,515
CREATE TABLE `patients` ( patient TEXT primary key, race TEXT ) CREATE TABLE `careplans` ( STOP DATE, PATIENT TEXT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "strftime", "INNER JOIN", "ON", "COUNT", "FROM" ]
9
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
How many male patients have prediabetes condition?
male refers to gender = 'M'; prediabetes condition refers to conditions.DESCRIPTION = 'Prediabetes';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 WHERE T2.DESCRIPTION = 'Prediabetes' AND T1.gender = 'M'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,516
1,516
CREATE TABLE `patients` ( patient TEXT primary key, gender TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "AND", "SELECT", "INNER JOIN", "COUNT", "FROM" ]
7
simple
{ "case_1": [ 1086 ], "case_2": [ 628, 746, 760, 1086 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 554, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 618, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 692, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 707, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 730, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 820, 822, 823, 824, 825, 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, 838, 839, 841, 843, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 903, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 945, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1079, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1126, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
List the full names of patients with nut allergy.
full names = first, last; nut allergy refers to allergies.DESCRIPTION = 'Allergy to nut';
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to nut'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,517
1,517
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `allergies` ( PATIENT TEXT, DESCRIPTION TEXT, primary key PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 132 ], "case_2": [ 132 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Describe the condition of patient Wilmer Koepp.
SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Wilmer' AND T1.last = 'Koepp'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,518
1,518
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 1086 ], "case_2": [ 628, 746, 760, 1086 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Among the patients with viral sinusitis condition, which patient's gender is most affected? Provide the number for each respectively.
viral sinusitis condition refers to conditions.DESCRIPTION = 'Viral sinusitis (disorder)'; gender that is most affected refers to MAX(COUNT(gender WHERE conditions.DESCRIPTION = 'Viral sinusitis (disorder)'));
SELECT SUM(CASE WHEN T1.gender = 'F' THEN 1 ELSE 0 END), SUM(CASE WHEN T1.gender = 'M' THEN 1 ELSE 0 END) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Viral sinusitis (disorder)'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,519
1,519
CREATE TABLE `patients` ( patient TEXT primary key, gender TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "CASE WHEN", "AS", "SELECT", "SUM", "CASE", "INNER JOIN", "ON", "FROM" ]
12
medium
{ "case_1": [ 628, 746, 760 ], "case_2": [ 628, 746, 760, 1086 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 54, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 122, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 205, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 508, 509, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 709, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 939, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 979, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1093, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1110, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Provide the full names of patients who have been taking Penicillin V Potassium 250 MG since 1948.
full names = first, last; Penicillin V Potassium 250 MG refers to medications.DESCRIPTION = 'Penicillin V Potassium 250 MG'; since 1948 refers to substr(medications.START, 1, 4) > = '1948';
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Penicillin V Potassium 250 MG' AND strftime('%Y', T2.START) >= '1948'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,520
1,520
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `medications` ( START DATE, PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, primary key START, PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "strftime", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ -1 ], "case_2": [ 53, 433, 693 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
How many white patients whose birth year is 1935 have a stroke?
white refers to race = 'white'; birth year is 1935 refers to substr(birthdate, 1, 4) = '1935'; stroke refers to conditions.DESCRIPTION = 'Stroke';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.patient WHERE strftime('%Y', T1.birthdate) = '1935' AND T1.race = 'white' AND T2.DESCRIPTION = 'Stroke'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,521
1,521
CREATE TABLE `patients` ( patient TEXT primary key, birthdate DATE, race TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "AND", "SELECT", "strftime", "INNER JOIN", "ON", "COUNT", "FROM" ]
10
simple
{ "case_1": [ 1086 ], "case_2": [ 628, 746, 760, 1086 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Which conditions the patient has when receiving the IPV immunization?
IPV immunization refers to immunizations.DESCRIPTION = 'IPV';
SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT INNER JOIN immunizations AS T3 ON T1.patient = T3.PATIENT WHERE T3.DESCRIPTION = 'IPV'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,522
1,522
CREATE TABLE `patients` ( patient TEXT primary key ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM ) CREATE TABLE `immunizations` ( PATIENT TEXT, DESCRIPTION TEXT, PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
9
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
List the patient ids whose disease has the most occurrences.
patient ids refers to patients.patient; disease with the most occurrence refers to MAX(all_prevalences.OCCURENCES);
SELECT T1.patient FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT INNER JOIN all_prevalences AS T3 ON T3.ITEM = T2.DESCRIPTION ORDER BY T3.OCCURRENCES DESC LIMIT 1
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,523
1,523
CREATE TABLE `all_prevalences` ( ITEM TEXT primary key, OCCURRENCES INTEGER ) CREATE TABLE `patients` ( patient TEXT primary key ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
12
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 208, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 252, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 285, 286, 287, 289, 290, 291, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 352, 353, 354, 356, 357, 358, 359, 360, 361, 363, 364, 365, 368, 369, 370, 371, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 619, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 664, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 836, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 869, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 946, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 972, 973, 974, 975, 977, 980, 981, 983, 985, 986, 987, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1030, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1057, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1076, 1077, 1078, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1139, 1141 ] }
synthea
List all the full names of patients with a condition described as cystitis.
full names = first, last; condition described as cystitis refers to conditions.DESCRIPTION = ''Cystitis';
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.patient WHERE T2.DESCRIPTION = 'Cystitis'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,524
1,524
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 1086 ], "case_2": [ 628, 746, 760, 1086 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
How many male patients have been described as immune to quadrivalent HPV?
male refers to gender = 'M'; immune to quadrivalent HPV refers to immunizations.DESCRIPTION = 'HPV quadrivalent';
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'HPV quadrivalent' AND T1.gender = 'M'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,525
1,525
CREATE TABLE `patients` ( patient TEXT primary key, gender TEXT ) CREATE TABLE `immunizations` ( PATIENT TEXT, DESCRIPTION TEXT, PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
8
simple
{ "case_1": [ 923 ], "case_2": [ 923, 1123 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 554, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 618, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 692, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 707, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 730, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 820, 822, 823, 824, 825, 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, 838, 839, 841, 843, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 903, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 945, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1079, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1126, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Indicate the start date of patient Walter Bahringer's care plan.
start date of the care plan refers to careplans.START;
SELECT DISTINCT T2.start FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Walter' AND T1.last = 'Bahringer'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,526
1,526
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `careplans` ( START DATE, PATIENT TEXT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Describe the care plans of patient Major D'Amore's plan of care.
SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Major' AND T1.last = 'D''Amore'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,527
1,527
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Calculate the percentage of male patients with viral sinusitis condition.
percentage = MULTIPLY(DIVIDE(COUNT(patients.patient WHERE gender = 'M'), COUNT(patients.patient) WHERE conditions.DESCRIPTION = 'Viral sinusitis (disorder))), 100); male patients refers to gender = 'M'; viral sinusitis condition refers to conditions.DESCRIPTION = 'Viral sinusitis (disorder)';
SELECT CAST(SUM(CASE WHEN T1.gender = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Viral sinusitis (disorder)'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,528
1,528
CREATE TABLE `patients` ( patient TEXT primary key, gender TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "CASE WHEN", "AS", "SELECT", "SUM", "CASE", "INNER JOIN", "ON", "CAST", "COUNT", "FROM" ]
12
medium
{ "case_1": [ 628, 760 ], "case_2": [ 628, 760, 1086 ], "case_3": [ 30, 53, 374, 516, 519, 544, 581, 628, 760, 923, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 4, 6, 11, 16, 22, 24, 27, 30, 35, 36, 37, 39, 42, 47, 51, 53, 55, 61, 62, 63, 64, 68, 69, 71, 73, 74, 75, 77, 81, 82, 83, 86, 87, 88, 91, 93, 94, 96, 98, 104, 106, 112, 113, 115, 117, 118, 119, 120, 121, 125, 126, 127, 129, 131, 140, 141, 142, 143, 146, 148, 152, 153, 155, 158, 159, 160, 164, 167, 169, 170, 171, 173, 175, 179, 183, 184, 186, 187, 188, 189, 190, 191, 192, 195, 196, 197, 199, 201, 202, 206, 207, 212, 213, 214, 215, 219, 223, 225, 226, 227, 228, 229, 233, 234, 236, 243, 244, 247, 248, 254, 256, 258, 261, 264, 267, 268, 269, 271, 276, 277, 278, 279, 298, 299, 300, 301, 304, 311, 313, 314, 316, 317, 319, 320, 322, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 347, 349, 354, 356, 358, 360, 363, 364, 365, 370, 373, 374, 375, 378, 379, 381, 382, 383, 384, 391, 392, 393, 394, 398, 401, 402, 403, 406, 409, 411, 412, 415, 416, 417, 423, 424, 426, 427, 436, 438, 444, 445, 448, 450, 451, 452, 453, 454, 458, 460, 462, 464, 465, 467, 469, 470, 471, 473, 476, 477, 478, 479, 483, 484, 485, 486, 487, 488, 490, 493, 500, 504, 505, 509, 510, 514, 515, 516, 517, 518, 519, 520, 526, 528, 532, 535, 536, 537, 538, 540, 544, 547, 548, 550, 552, 558, 559, 560, 563, 564, 566, 571, 573, 575, 579, 580, 581, 582, 595, 596, 597, 606, 608, 609, 611, 612, 613, 620, 623, 627, 628, 630, 632, 633, 634, 638, 640, 641, 645, 646, 649, 650, 654, 658, 659, 662, 663, 665, 666, 668, 669, 671, 672, 676, 681, 682, 686, 687, 688, 690, 694, 695, 696, 701, 705, 706, 710, 712, 714, 717, 721, 723, 727, 733, 734, 735, 736, 739, 740, 743, 744, 745, 747, 749, 750, 752, 753, 756, 760, 762, 768, 769, 772, 776, 777, 778, 779, 787, 788, 790, 795, 796, 797, 798, 799, 800, 802, 804, 805, 808, 810, 812, 813, 814, 818, 819, 823, 824, 825, 827, 830, 832, 838, 839, 841, 844, 848, 849, 851, 853, 857, 866, 867, 868, 870, 871, 874, 876, 877, 880, 886, 888, 893, 894, 896, 897, 898, 901, 902, 909, 911, 912, 913, 915, 917, 918, 922, 923, 924, 926, 927, 930, 934, 935, 941, 943, 944, 950, 951, 954, 956, 958, 959, 961, 962, 963, 969, 973, 975, 977, 981, 985, 986, 993, 996, 998, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1022, 1023, 1027, 1031, 1037, 1038, 1042, 1043, 1047, 1050, 1051, 1058, 1062, 1064, 1066, 1067, 1068, 1069, 1071, 1072, 1078, 1082, 1084, 1086, 1087, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1106, 1112, 1119, 1121, 1123, 1124, 1128, 1131, 1133, 1134, 1135, 1137 ] }
synthea
Among the patients who have been using Penicillin V Potassium 250 MG, what percentage of patients are female?
Penicillin V Potassium 250 MG refers to medications.DESCRIPTION = 'Penicillin V Potassium 250 MG'; percentage = MULTIPLY(DIVIDE(patients.patient WHERE gender = 'F'), COUNT(patients.patient) WHERE medications.DESCRIPTION = 'Penicillin V Potassium 250 MG'), 100) female refers to gender = 'F';
SELECT CAST(SUM(CASE WHEN T1.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.patient) FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Penicillin V Potassium 250 MG'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,529
1,529
CREATE TABLE `patients` ( patient TEXT primary key, gender TEXT ) CREATE TABLE `medications` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, PATIENT, foreign key PATIENT references patientspatient )
[ "CASE WHEN", "AS", "SELECT", "SUM", "CASE", "INNER JOIN", "ON", "CAST", "COUNT", "FROM" ]
12
medium
{ "case_1": [ 53 ], "case_2": [ 53 ], "case_3": [ 30, 53, 374, 516, 519, 544, 581, 628, 760, 923, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 4, 6, 11, 16, 22, 24, 27, 30, 35, 36, 37, 39, 42, 47, 51, 53, 55, 61, 62, 63, 64, 68, 69, 71, 73, 74, 75, 77, 81, 82, 83, 86, 87, 88, 91, 93, 94, 96, 98, 104, 106, 112, 113, 115, 117, 118, 119, 120, 121, 125, 126, 127, 129, 131, 140, 141, 142, 143, 146, 148, 152, 153, 155, 158, 159, 160, 164, 167, 169, 170, 171, 173, 175, 179, 183, 184, 186, 187, 188, 189, 190, 191, 192, 195, 196, 197, 199, 201, 202, 206, 207, 212, 213, 214, 215, 219, 223, 225, 226, 227, 228, 229, 233, 234, 236, 243, 244, 247, 248, 254, 256, 258, 261, 264, 267, 268, 269, 271, 276, 277, 278, 279, 298, 299, 300, 301, 304, 311, 313, 314, 316, 317, 319, 320, 322, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 347, 349, 354, 356, 358, 360, 363, 364, 365, 370, 373, 374, 375, 378, 379, 381, 382, 383, 384, 391, 392, 393, 394, 398, 401, 402, 403, 406, 409, 411, 412, 415, 416, 417, 423, 424, 426, 427, 436, 438, 444, 445, 448, 450, 451, 452, 453, 454, 458, 460, 462, 464, 465, 467, 469, 470, 471, 473, 476, 477, 478, 479, 483, 484, 485, 486, 487, 488, 490, 493, 500, 504, 505, 509, 510, 514, 515, 516, 517, 518, 519, 520, 526, 528, 532, 535, 536, 537, 538, 540, 544, 547, 548, 550, 552, 558, 559, 560, 563, 564, 566, 571, 573, 575, 579, 580, 581, 582, 595, 596, 597, 606, 608, 609, 611, 612, 613, 620, 623, 627, 628, 630, 632, 633, 634, 638, 640, 641, 645, 646, 649, 650, 654, 658, 659, 662, 663, 665, 666, 668, 669, 671, 672, 676, 681, 682, 686, 687, 688, 690, 694, 695, 696, 701, 705, 706, 710, 712, 714, 717, 721, 723, 727, 733, 734, 735, 736, 739, 740, 743, 744, 745, 747, 749, 750, 752, 753, 756, 760, 762, 768, 769, 772, 776, 777, 778, 779, 787, 788, 790, 795, 796, 797, 798, 799, 800, 802, 804, 805, 808, 810, 812, 813, 814, 818, 819, 823, 824, 825, 827, 830, 832, 838, 839, 841, 844, 848, 849, 851, 853, 857, 866, 867, 868, 870, 871, 874, 876, 877, 880, 886, 888, 893, 894, 896, 897, 898, 901, 902, 909, 911, 912, 913, 915, 917, 918, 922, 923, 924, 926, 927, 930, 934, 935, 941, 943, 944, 950, 951, 954, 956, 958, 959, 961, 962, 963, 969, 973, 975, 977, 981, 985, 986, 993, 996, 998, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1022, 1023, 1027, 1031, 1037, 1038, 1042, 1043, 1047, 1050, 1051, 1058, 1062, 1064, 1066, 1067, 1068, 1069, 1071, 1072, 1078, 1082, 1084, 1086, 1087, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1106, 1112, 1119, 1121, 1123, 1124, 1128, 1131, 1133, 1134, 1135, 1137 ] }
synthea
Among the white patients, what is the average body height of the patients?
white refers to race = 'white'; average body height = AVG(observations.VALUE WHERE observations.DESCRIPTION = 'Body Height'); body height refers to observations.DESCRIPTION = 'Body Height';
SELECT AVG(T1.VALUE) FROM observations AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.race = 'white' AND T1.DESCRIPTION = 'Body Height'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,530
1,530
CREATE TABLE `patients` ( patient TEXT primary key, race TEXT ) CREATE TABLE `observations` ( PATIENT TEXT, DESCRIPTION TEXT, VALUE REAL, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "AVG", "FROM" ]
8
simple
{ "case_1": [ 519, 1046 ], "case_2": [ 519, 1046 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 864, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1081, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Indicate the care plan needed for the patient living at 179 Sydni Roads, Taunton, MA 02780 US.
living at 179 Sydni Roads, Taunton, MA 02780 US refers to address = '179 Sydni Roads Taunton MA 02780 US';
SELECT T1.DESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.address = '179 Sydni Roads Taunton MA 02780 US'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,531
1,531
CREATE TABLE `patients` ( patient TEXT primary key, address TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Provide the allergen of the Dominican patient named Dirk Languish.
allergen refers to allergies.DESCRIPTION;
SELECT T1.DESCRIPTION FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Dirk' AND T2.last = 'Langosh' AND T2.ethnicity = 'dominican'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,532
1,532
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT, ethnicity TEXT ) CREATE TABLE `allergies` ( PATIENT TEXT, DESCRIPTION TEXT, primary key PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ 132 ], "case_2": [ 132 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
How many patients who are allergic to peanuts have asthma?
allergic to peanuts refers to allergies.DESCRIPTION = 'Allergy to peanuts'; asthma refers to conditions.DESCRIPTION = 'Asthma';
SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN allergies AS T3 ON T2.patient = T3.PATIENT WHERE T1.DESCRIPTION = 'Asthma' AND T3.DESCRIPTION = 'Allergy to peanuts'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,533
1,533
CREATE TABLE `patients` ( patient TEXT primary key ) CREATE TABLE `allergies` ( PATIENT TEXT, DESCRIPTION TEXT, primary key PATIENT, foreign key PATIENT references patientspatient ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
11
medium
{ "case_1": [ 374 ], "case_2": [ 374 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 554, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 618, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 692, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 707, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 730, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 820, 822, 823, 824, 825, 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, 838, 839, 841, 843, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 903, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 945, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1079, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1126, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Who is the 44-year-old patient diagnosed with drug overdose?
44-year-old = DIVIDE(SUBTRACT(julianday(conditions.START), julianday(patients.birthdate)), 365, 0) = 44;
SELECT T2.first, T2.last FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Drug overdose' AND ROUND((strftime('%J', T2.deathdate) - strftime('%J', T2.birthdate)) / 365) = 44
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,534
1,534
CREATE TABLE `patients` ( patient TEXT primary key, birthdate DATE, deathdate DATE, first TEXT, last TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "AND", "SELECT", "ROUND", "strftime", "INNER JOIN", "ON", "FROM" ]
10
simple
{ "case_1": [ 1086 ], "case_2": [ 628, 746, 760, 1086 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Provide the social security number of the patient with the highest systolic blood pressure.
social security number refers to ssn; highest systolic blood pressure refers to MAX(observations.VALUE WHERE observations.DESCRIPTION = 'Systolic Blood Pressure');
SELECT T2.ssn FROM observations AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Systolic Blood Pressure' ORDER BY T1.VALUE DESC LIMIT 1
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,535
1,535
CREATE TABLE `patients` ( patient TEXT primary key, ssn TEXT ) CREATE TABLE `observations` ( PATIENT TEXT, DESCRIPTION TEXT, VALUE REAL, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
9
simple
{ "case_1": [ 519, 1046 ], "case_2": [ 519, 1046 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 208, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 252, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 285, 286, 287, 289, 290, 291, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 352, 353, 354, 356, 357, 358, 359, 360, 361, 363, 364, 365, 368, 369, 370, 371, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 619, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 664, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 836, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 869, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 946, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 972, 973, 974, 975, 977, 980, 981, 983, 985, 986, 987, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1030, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1057, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1076, 1077, 1078, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1139, 1141 ] }
synthea
What is the care plan description of the prevalent disease with the highest prevalence percentage?
highest prevalence percentage refers to MAX(PREVALENCE PERCENTAGE);
SELECT T4.DESCRIPTION FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON T2.DESCRIPTION = T1.ITEM INNER JOIN encounters AS T3 ON T2.ENCOUNTER = T3.ID INNER JOIN careplans AS T4 ON T4.ENCOUNTER = T3.ID ORDER BY T1."PREVALENCE PERCENTAGE" DESC LIMIT 1
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,536
1,536
CREATE TABLE `all_prevalences` ( ITEM TEXT primary key, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE `encounters` ( ID TEXT primary key, DESCRIPTION TEXT, REASONDESCRIPTION TEXT ) CREATE TABLE `careplans` ( ID TEXT, ENCOUNTER TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key ENCOUNTER references encountersID ) CREATE TABLE `conditions` ( ENCOUNTER TEXT, DESCRIPTION TEXT, foreign key ENCOUNTER references encountersID, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
15
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 208, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 252, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 285, 286, 287, 289, 290, 291, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 352, 353, 354, 356, 357, 358, 359, 360, 361, 363, 364, 365, 368, 369, 370, 371, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 619, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 664, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 836, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 869, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 946, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 972, 973, 974, 975, 977, 980, 981, 983, 985, 986, 987, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1030, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1057, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1076, 1077, 1078, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1139, 1141 ] }
synthea
What is the care plan for the patient with social security number 999-15-3685?
social security number refers to ssn; ssn = '999-15-3685';
SELECT DISTINCT T1.DESCRIPTION FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ssn = '999-15-3685'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,537
1,537
CREATE TABLE `patients` ( patient TEXT primary key, ssn TEXT ) CREATE TABLE `careplans` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "-", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ 30 ], "case_2": [ 30 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Calculate the average age of the male patients that have hypertension.
average age = AVG(DIVIDE(SUBTRACT(deathdate is null WHERE (julianday(substr(datetime('now'), 1, 10)))), julianday(patients.birthdate)), 365); male refers to gender = 'M'; hypertension refers to conditions.DESCRIPTION = 'Hypertension'
SELECT SUM(CASE WHEN T2.deathdate IS NULL THEN ROUND((strftime('%J', date('now')) - strftime('%J', T2.birthdate)) / 365) ELSE ROUND((strftime('%J', T2.deathdate) - strftime('%J', T2.birthdate)) / 365) END) / COUNT(T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Hypertension' AND T2.gender = 'M'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,538
1,538
CREATE TABLE `patients` ( patient TEXT primary key, birthdate DATE, deathdate DATE, gender TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "CASE WHEN", "AS", "AND", "SELECT", "ROUND", "SUM", "strftime", "now", "CASE", "NULL", "INNER JOIN", "ON", "COUNT", "IS", "FROM" ]
20
challenging
{ "case_1": [ -1 ], "case_2": [ 628, 1086 ], "case_3": [ 53, 516, 581, 628, 923, 1086 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 6, 16, 24, 42, 53, 64, 71, 77, 81, 93, 106, 113, 120, 127, 129, 138, 148, 152, 153, 155, 158, 169, 171, 184, 191, 195, 201, 207, 212, 219, 225, 226, 234, 236, 248, 258, 261, 264, 267, 279, 298, 299, 300, 304, 317, 335, 347, 360, 375, 383, 393, 395, 398, 402, 406, 412, 415, 427, 436, 438, 448, 452, 476, 478, 479, 486, 493, 500, 514, 516, 518, 522, 528, 533, 535, 537, 540, 547, 550, 563, 564, 571, 573, 575, 580, 581, 589, 612, 620, 623, 628, 637, 640, 646, 662, 666, 672, 676, 682, 686, 706, 710, 712, 723, 740, 744, 747, 753, 762, 772, 776, 787, 788, 796, 798, 800, 805, 808, 827, 841, 844, 848, 868, 870, 871, 874, 880, 894, 896, 909, 912, 922, 923, 924, 926, 927, 935, 941, 943, 944, 958, 959, 985, 1008, 1012, 1023, 1031, 1062, 1064, 1066, 1069, 1078, 1082, 1086, 1087, 1092, 1098, 1100, 1131, 1133, 1134, 1135 ] }
synthea
List 5 patients' name that need medication due to streptococcal sore throat disorder.
patients name = first, last; streptococcal sore throat disorder refers to medications.REASONDESCRIPTION = 'Streptococcal sore throat (disorder)';
SELECT DISTINCT T2.first, T2.last FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.REASONDESCRIPTION = 'Streptococcal sore throat (disorder)' LIMIT 5
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,539
1,539
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `medications` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "SELECT", "LIMIT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ -1 ], "case_2": [ 53, 433, 693 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Who is the patient with a body weight of 61.97 kg?
body weight of 61.97 kg refers to observations.DESCRIPTION = 'Body Weight' AND observations.VALUE = 61.97; observations.UNITS = 'kg'
SELECT T2.first, T2.last FROM observations AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Body Weight' AND T1.UNITS = 'kg' AND T1.VALUE = 61.97
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,540
1,540
CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT ) CREATE TABLE `observations` ( PATIENT TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ 519, 1046 ], "case_2": [ 519, 1046 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
Among the male patients, list down 5 birth dates of patients taking the medication "Penicillin V Potassium 250 MG".
male patients refers to gender = 'M'; Penicillin V Potassium 250 MG refers to medications.DESCRIPTION = 'Penicillin V Potassium 250 MG';
SELECT DISTINCT T2.birthdate FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Penicillin V Potassium 250 MG' AND T2.gender = 'M' LIMIT 5
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,541
1,541
CREATE TABLE `patients` ( patient TEXT primary key, birthdate DATE, gender TEXT ) CREATE TABLE `medications` ( PATIENT TEXT, DESCRIPTION TEXT, REASONDESCRIPTION TEXT, PATIENT, foreign key PATIENT references patientspatient )
[ "AS", "AND", "SELECT", "LIMIT", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ -1 ], "case_2": [ 53, 433, 693 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
List down the full name of Irish patients diagnosed with the prevalent diseases that have an occurrence greater than the 96% of the average occurrences of all conditions.
full name = first, last; Irish refers to ethnicity = 'irish'; prevalent diseases that have an occurrence greater than the 96% of the average occurrences of all conditions = OCCURRENCES > (AVG(MULTIPLY(all_prevalences.OCCURRENCES, 0.96)));
SELECT DISTINCT T2.first, T2.last FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN all_prevalences AS T3 ON T1.DESCRIPTION = T3.ITEM WHERE T2.ethnicity = 'irish' AND 100 * CAST(T3.OCCURRENCES AS REAL) / ( SELECT AVG(OCCURRENCES) FROM all_prevalences ) > 96
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,542
1,542
CREATE TABLE `all_prevalences` ( ITEM TEXT primary key, OCCURRENCES INTEGER ) CREATE TABLE `patients` ( patient TEXT primary key, first TEXT, last TEXT, ethnicity TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "AVG", "CAST", "FROM" ]
15
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
synthea
What is the difference between the number of married patients and the number of single patients with diabetes?
difference = SUBTRACT(patients.patient WHERE marital = 'M'), COUNT(patients.patient WHERE marital = 'S') WHERE conditions.DESCRIPTION = 'Diabetes'); married patients refers to marital = 'M'; single patients refers to marital = 'S'; diabetes refers to conditions.DESCRIPTION = 'Diabetes';
SELECT SUM(CASE WHEN T2.marital = 'M' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.marital = 'S' THEN 1 ELSE 0 END) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Diabetes'
CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) )
CREATE TABLE all_prevalences ( ITEM TEXT primary key, "POPULATION TYPE" TEXT, OCCURRENCES INTEGER, "POPULATION COUNT" INTEGER, "PREVALENCE RATE" REAL, "PREVALENCE PERCENTAGE" REAL ) CREATE TABLE patients ( patient TEXT primary key, birthdate DATE, deathdate DATE, ssn TEXT, drivers TEXT, passport TEXT, prefix TEXT, first TEXT, last TEXT, suffix TEXT, maiden TEXT, marital TEXT, race TEXT, ethnicity TEXT, gender TEXT, birthplace TEXT, address TEXT ) CREATE TABLE encounters ( ID TEXT primary key, DATE DATE, PATIENT TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (PATIENT) references patients(patient) ) CREATE TABLE allergies ( START TEXT, STOP TEXT, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE careplans ( ID TEXT, START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE REAL, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE conditions ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient), foreign key (DESCRIPTION) references all_prevalences(ITEM) ) CREATE TABLE immunizations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, primary key (DATE, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE medications ( START DATE, STOP DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, primary key (START, PATIENT, ENCOUNTER, CODE), foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE observations ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE TEXT, DESCRIPTION TEXT, VALUE REAL, UNITS TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE procedures ( DATE DATE, PATIENT TEXT, ENCOUNTER TEXT, CODE INTEGER, DESCRIPTION TEXT, REASONCODE INTEGER, REASONDESCRIPTION TEXT, foreign key (ENCOUNTER) references encounters(ID), foreign key (PATIENT) references patients(patient) ) CREATE TABLE "claims" ( ID TEXT primary key, PATIENT TEXT references patients, BILLABLEPERIOD DATE, ORGANIZATION TEXT, ENCOUNTER TEXT references encounters, DIAGNOSIS TEXT, TOTAL INTEGER )
na
1,543
1,543
CREATE TABLE `patients` ( patient TEXT primary key, marital TEXT ) CREATE TABLE `conditions` ( PATIENT TEXT, DESCRIPTION TEXT, foreign key PATIENT references patientspatient, foreign key DESCRIPTION references all_prevalencesITEM )
[ "CASE WHEN", "AS", "SELECT", "SUM", "CASE", "INNER JOIN", "ON", "FROM" ]
12
medium
{ "case_1": [ 628, 746, 760 ], "case_2": [ 628, 746, 760, 1086 ], "case_3": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_4": [ 30, 53, 132, 172, 374, 431, 433, 516, 519, 544, 581, 628, 693, 746, 760, 923, 974, 1046, 1086, 1123 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 54, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 122, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 205, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 508, 509, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 709, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 939, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 979, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1093, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1110, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
List the country and how many customers are there.
SELECT country, COUNT(customerNumber) FROM customers GROUP BY country
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,544
1,544
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, country TEXT not null )
[ "GROUP BY", "COUNT", "SELECT", "FROM" ]
4
simple
{ "case_1": [ 730 ], "case_2": [ 730 ], "case_3": [ 16, 379, 718, 730, 798, 843 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 4, 6, 9, 11, 13, 15, 16, 20, 22, 25, 27, 28, 30, 32, 35, 36, 37, 40, 47, 51, 53, 55, 61, 62, 63, 67, 68, 69, 73, 74, 75, 77, 78, 82, 86, 87, 88, 89, 91, 93, 96, 98, 106, 108, 109, 113, 115, 117, 118, 119, 121, 124, 125, 126, 131, 140, 142, 143, 146, 147, 148, 152, 157, 159, 160, 164, 167, 169, 170, 173, 175, 179, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 196, 197, 198, 199, 202, 203, 206, 210, 212, 213, 214, 216, 224, 225, 226, 227, 229, 230, 233, 234, 243, 244, 247, 252, 254, 256, 259, 261, 267, 268, 269, 271, 273, 276, 277, 285, 286, 291, 293, 294, 299, 301, 303, 311, 313, 314, 316, 317, 319, 320, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 348, 349, 352, 354, 356, 358, 359, 360, 364, 365, 370, 371, 373, 374, 375, 377, 378, 379, 380, 381, 382, 383, 384, 391, 392, 394, 399, 401, 403, 406, 409, 410, 411, 412, 416, 417, 420, 421, 423, 424, 426, 436, 443, 444, 445, 447, 448, 453, 454, 458, 460, 462, 464, 465, 466, 467, 469, 471, 473, 476, 477, 478, 481, 484, 485, 487, 488, 490, 493, 500, 504, 505, 509, 510, 512, 515, 516, 517, 519, 520, 526, 531, 532, 535, 536, 537, 538, 542, 543, 544, 545, 547, 548, 551, 552, 554, 558, 559, 560, 563, 564, 566, 573, 579, 580, 581, 582, 585, 586, 591, 594, 595, 596, 597, 598, 603, 606, 608, 611, 613, 618, 620, 627, 629, 630, 632, 633, 634, 638, 641, 645, 646, 649, 651, 654, 656, 658, 659, 661, 662, 663, 664, 665, 667, 668, 669, 671, 673, 680, 681, 687, 688, 689, 690, 692, 694, 696, 698, 701, 703, 705, 707, 712, 714, 718, 719, 720, 721, 727, 730, 733, 734, 735, 736, 737, 739, 740, 743, 748, 749, 750, 751, 752, 753, 756, 757, 760, 762, 768, 769, 770, 772, 778, 779, 787, 790, 795, 796, 797, 798, 799, 800, 802, 804, 810, 811, 812, 813, 814, 817, 818, 819, 820, 821, 823, 824, 827, 830, 831, 838, 839, 841, 843, 849, 851, 853, 857, 865, 866, 867, 869, 870, 874, 876, 877, 882, 886, 888, 889, 890, 893, 894, 896, 897, 898, 899, 901, 902, 903, 909, 911, 912, 913, 915, 917, 918, 922, 923, 924, 926, 927, 929, 930, 932, 934, 935, 941, 942, 943, 945, 950, 951, 954, 956, 958, 960, 961, 962, 963, 965, 968, 969, 972, 973, 975, 976, 977, 981, 983, 985, 986, 987, 993, 996, 1005, 1006, 1008, 1010, 1011, 1013, 1014, 1015, 1020, 1022, 1023, 1025, 1030, 1037, 1042, 1043, 1047, 1050, 1051, 1053, 1055, 1057, 1058, 1059, 1062, 1064, 1067, 1069, 1070, 1071, 1072, 1076, 1077, 1078, 1079, 1082, 1084, 1086, 1087, 1090, 1091, 1094, 1096, 1100, 1101, 1103, 1104, 1106, 1108, 1112, 1113, 1119, 1121, 1123, 1124, 1126, 1127, 1128, 1131, 1133, 1134, 1135, 1137 ] }
car_retails
Which different vendor has the most amount of orders? Calculate the total estimated earnings.
amount of order refers to quantityOrdered; most amount of orders refers to SUM(QuantityOrdered); estimated earnings refers to expected profits; expected profits = SUBTRACT(msrp, buyPrice);
SELECT DISTINCT T1.productVendor, T1.MSRP - T1.buyPrice FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode GROUP BY T1.productVendor, T1.MSRP, T1.buyPrice ORDER BY COUNT(T2.quantityOrdered) DESC LIMIT 1
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,545
1,545
CREATE TABLE `products` ( productCode TEXT not null primary key, productVendor TEXT not null, MSRP REAL not null ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, quantityOrdered INTEGER not null, productCode )
[ "GROUP BY", "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "COUNT", "FROM" ]
11
medium
{ "case_1": [ 1038 ], "case_2": [ 1038 ], "case_3": [ 16, 379, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 4, 6, 10, 11, 13, 15, 16, 20, 22, 27, 28, 29, 30, 36, 37, 47, 49, 51, 53, 55, 59, 62, 63, 68, 69, 73, 74, 75, 77, 78, 82, 86, 88, 89, 91, 93, 96, 98, 106, 108, 113, 115, 117, 118, 119, 121, 125, 126, 131, 138, 140, 142, 143, 146, 148, 150, 152, 159, 160, 162, 163, 164, 167, 169, 170, 173, 175, 179, 183, 184, 185, 187, 188, 189, 190, 191, 196, 197, 199, 200, 202, 206, 212, 213, 214, 225, 226, 227, 229, 233, 234, 239, 243, 244, 247, 252, 254, 256, 261, 262, 267, 268, 269, 275, 276, 277, 278, 281, 285, 286, 291, 299, 301, 309, 311, 313, 314, 316, 317, 319, 320, 323, 324, 325, 329, 330, 334, 335, 336, 338, 339, 341, 342, 344, 345, 348, 349, 352, 353, 354, 356, 358, 359, 360, 364, 365, 370, 371, 373, 374, 375, 378, 379, 381, 382, 383, 384, 385, 391, 392, 394, 395, 401, 403, 406, 409, 411, 412, 416, 417, 424, 426, 428, 429, 434, 435, 436, 444, 445, 448, 451, 454, 460, 462, 464, 465, 467, 469, 471, 473, 476, 477, 478, 482, 484, 487, 488, 490, 493, 495, 497, 500, 505, 509, 515, 516, 519, 520, 526, 530, 532, 535, 536, 537, 538, 542, 544, 547, 548, 552, 558, 559, 560, 563, 564, 566, 567, 573, 578, 579, 580, 581, 582, 584, 586, 590, 592, 595, 596, 597, 606, 608, 611, 613, 620, 621, 625, 626, 627, 630, 632, 633, 634, 637, 638, 641, 645, 646, 649, 651, 654, 657, 658, 659, 662, 663, 664, 665, 668, 669, 671, 681, 687, 688, 690, 691, 694, 696, 698, 701, 703, 705, 712, 714, 719, 720, 721, 727, 733, 734, 735, 736, 739, 740, 743, 748, 749, 750, 751, 752, 753, 756, 759, 760, 762, 768, 769, 772, 778, 779, 787, 790, 796, 797, 799, 800, 802, 803, 804, 810, 812, 813, 814, 818, 819, 823, 824, 827, 830, 838, 839, 841, 849, 850, 851, 853, 857, 861, 866, 867, 869, 870, 874, 876, 877, 882, 886, 888, 889, 891, 893, 896, 897, 898, 901, 902, 909, 911, 912, 915, 917, 918, 922, 923, 924, 926, 927, 929, 930, 932, 934, 935, 943, 950, 951, 953, 954, 956, 958, 961, 962, 963, 966, 967, 969, 970, 972, 973, 975, 977, 981, 983, 985, 986, 987, 993, 994, 996, 1004, 1005, 1006, 1010, 1013, 1015, 1017, 1022, 1023, 1025, 1030, 1034, 1037, 1038, 1042, 1043, 1047, 1049, 1050, 1051, 1056, 1057, 1058, 1062, 1064, 1065, 1067, 1068, 1071, 1072, 1076, 1077, 1078, 1082, 1084, 1086, 1087, 1091, 1094, 1100, 1101, 1103, 1104, 1106, 1112, 1119, 1123, 1124, 1128, 1131, 1133, 1134, 1135, 1137 ] }
car_retails
Who is the sales agent of the distinct customer who paid the highest amount in the year 2004?
SELECT DISTINCT T3.lastName, T3.firstName FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber INNER JOIN employees AS T3 ON T2.salesRepEmployeeNumber = T3.employeeNumber WHERE STRFTIME('%Y', T1.paymentDate) = '2004' ORDER BY T1.amount DESC LIMIT 1
CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,546
1,546
CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, salesRepEmployeeNumber INTEGER, foreign key salesRepEmployeeNumber references employeesemployeeNumber ) CREATE TABLE `payments` ( customerNumber INTEGER not null, paymentDate DATE not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "STRFTIME", "FROM" ]
13
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 208, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 252, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 285, 286, 287, 289, 290, 291, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 352, 353, 354, 356, 357, 358, 359, 360, 361, 363, 364, 365, 368, 369, 370, 371, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 619, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 664, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 836, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 869, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 946, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 972, 973, 974, 975, 977, 980, 981, 983, 985, 986, 987, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1030, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1057, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1075, 1076, 1077, 1078, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1139, 1141 ] }
car_retails
What was the total price of the products shipped to Rovelli Gifts Distributors Ltd. between 1/1/2003 and 12/31/2003?
Mini Gifts Distributors Ltd. Is the customer name; shippedDate between '2003-01-01' and '2003-12-31'; total price = MULTIPLY(quantityOrdered, priceEach);
SELECT T3.priceEach * T3.quantityOrdered FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber INNER JOIN orderdetails AS T3 ON T2.orderNumber = T3.orderNumber WHERE T1.customerName = 'Rovelli Gifts' AND T2.status = 'Shipped' AND STRFTIME('%Y', T2.shippedDate) = '2003'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,547
1,547
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, customerName TEXT not null ) CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, shippedDate DATE, status TEXT not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, quantityOrdered INTEGER not null, priceEach REAL not null, primary key orderNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "STRFTIME", "FROM" ]
12
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 718, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many employees are there in Sydney?
sales agent and sales representative are synonyms; Sydney is a city;
SELECT COUNT(employeeNumber) FROM employees WHERE officeCode = ( SELECT officeCode FROM offices WHERE city = 'Sydney' )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,548
1,548
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, officeCode TEXT not null, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber )
[ "COUNT", "SELECT", "FROM" ]
5
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141 ] }
car_retails
Which sales representatives in New York city whose leader is Anthony Bow with the employee number is 1143? Indicate their employee numbers.
reportsTO' is the leader of the 'employeeNumber';
SELECT T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1143 AND T2.city = 'NYC'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,549
1,549
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, officeCode TEXT not null, reportsTo INTEGER, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
What is the average, highest and lowest annual payments collected between 1/1/2003 to 12/31/2005?
paymentDate BETWEEN '2003-01-01' AND '2005-12-31'; average annual payments = DIVIDE(SUM(amount), 3);
SELECT CAST(SUM(T1.amount) AS REAL) / 3, MAX(T1.amount) , MIN(T1.amount) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.paymentDate BETWEEN '2003-01-01' AND '2005-12-31'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,550
1,550
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key ) CREATE TABLE `payments` ( customerNumber INTEGER not null, paymentDate DATE not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "AND", "SELECT", "SUM", "-", "INNER JOIN", "ON", "CAST", "MIN", "BETWEEN", "FROM", "MAX" ]
17
challenging
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 470, 798 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 6, 21, 24, 39, 42, 45, 64, 71, 72, 74, 76, 77, 85, 93, 98, 112, 113, 115, 119, 120, 127, 128, 129, 141, 148, 152, 154, 158, 169, 172, 180, 183, 184, 187, 189, 195, 197, 201, 212, 219, 223, 225, 226, 228, 234, 236, 240, 244, 248, 254, 256, 261, 264, 267, 272, 278, 296, 300, 304, 316, 317, 319, 323, 325, 335, 339, 347, 356, 360, 368, 382, 383, 391, 393, 402, 403, 406, 409, 412, 416, 425, 427, 436, 438, 444, 446, 448, 451, 452, 463, 470, 476, 482, 483, 487, 493, 496, 498, 500, 507, 510, 514, 520, 522, 529, 530, 535, 537, 540, 544, 547, 550, 557, 559, 562, 563, 564, 575, 580, 581, 588, 597, 612, 623, 624, 633, 643, 658, 662, 666, 675, 676, 677, 684, 686, 690, 693, 695, 710, 740, 744, 746, 747, 750, 753, 754, 756, 758, 762, 767, 776, 777, 787, 788, 796, 798, 800, 802, 808, 810, 813, 825, 829, 832, 835, 838, 841, 848, 849, 858, 870, 874, 878, 896, 905, 909, 912, 917, 922, 924, 930, 932, 943, 944, 954, 958, 959, 974, 985, 1023, 1027, 1031, 1064, 1067, 1068, 1072, 1078, 1082, 1087, 1092, 1100, 1101, 1123, 1128 ] }
car_retails
Which countries do the top 5 highest paying customers in a single payment come from? Indicate their entire address.
highest paying customer refers to MAX(amount); entire address = addressLine1+addressLine2;
SELECT DISTINCT T2.country, T2.addressLine1, T2.addressLine2 FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber ORDER BY T1.amount DESC LIMIT 5
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,551
1,551
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, addressLine1 TEXT not null, addressLine2 TEXT, country TEXT not null ) CREATE TABLE `payments` ( customerNumber INTEGER not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
9
simple
{ "case_1": [ 523, 609 ], "case_2": [ 523, 609 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 208, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 252, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 285, 286, 287, 289, 290, 291, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 352, 353, 354, 356, 357, 358, 359, 360, 361, 363, 364, 365, 368, 369, 370, 371, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 619, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 664, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 836, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 869, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 946, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 972, 973, 974, 975, 977, 980, 981, 983, 985, 986, 987, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1030, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1057, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1076, 1077, 1078, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1139, 1141 ] }
car_retails
How many checks were issued by Euro+ Shopping Channel in the year 2004?
Euro+ Shopping Channel is a customer name; year(paymentDate) = '2004';
SELECT COUNT(T1.checkNumber) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE customerName = 'Euro+ Shopping Channel' AND STRFTIME('%Y', T1.paymentDate) = '2004'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,552
1,552
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, customerName TEXT not null ) CREATE TABLE `payments` ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, primary key customerNumber, checkNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "STRFTIME", "COUNT", "FROM" ]
9
simple
{ "case_1": [ 523, 609 ], "case_2": [ 523, 609 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 718, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Of all the classic cars, with a product scale of 1:18, which product is the most ordered product by customers?
classic car is a product line; most ordered product refers to MAX(quantityOrdered);
SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode WHERE T1.productScale = '1:18' AND T1.productLine = 'Classic Cars' GROUP BY T1.productName ORDER BY SUM(T2.quantityOrdered) DESC LIMIT 1
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,553
1,553
CREATE TABLE `products` ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, foreign key productLine references productlinesproductLine ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, quantityOrdered INTEGER not null, productCode )
[ "GROUP BY", "AS", "AND", "SELECT", "SUM", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
12
medium
{ "case_1": [ 1038 ], "case_2": [ 1038 ], "case_3": [ 8, 379, 470, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 4, 5, 6, 8, 10, 11, 12, 13, 15, 19, 20, 21, 22, 24, 26, 28, 29, 30, 33, 36, 37, 38, 39, 42, 44, 45, 47, 49, 51, 52, 53, 55, 57, 59, 62, 63, 64, 66, 68, 69, 71, 73, 74, 75, 76, 77, 78, 81, 83, 85, 86, 88, 89, 90, 93, 94, 95, 96, 98, 99, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 148, 150, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 167, 169, 170, 172, 173, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 191, 195, 197, 199, 200, 201, 202, 206, 207, 212, 213, 214, 219, 225, 226, 227, 228, 229, 233, 234, 236, 239, 240, 244, 247, 248, 252, 254, 256, 258, 261, 262, 264, 265, 266, 267, 268, 272, 275, 276, 277, 278, 279, 281, 282, 285, 286, 296, 300, 301, 304, 309, 311, 313, 314, 315, 316, 317, 319, 320, 323, 324, 325, 329, 330, 334, 335, 336, 339, 341, 342, 344, 345, 347, 348, 349, 352, 353, 356, 359, 360, 361, 363, 364, 365, 368, 370, 371, 373, 374, 376, 378, 379, 381, 382, 383, 385, 391, 393, 394, 395, 398, 402, 403, 405, 406, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 424, 425, 426, 427, 428, 429, 433, 434, 435, 436, 437, 438, 440, 444, 445, 446, 448, 450, 451, 452, 454, 455, 460, 462, 463, 464, 469, 470, 473, 475, 476, 477, 480, 482, 483, 486, 487, 488, 490, 493, 494, 495, 496, 497, 498, 500, 505, 507, 514, 515, 516, 518, 519, 520, 522, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 557, 558, 559, 560, 561, 562, 563, 564, 566, 567, 571, 575, 578, 579, 580, 581, 582, 584, 586, 588, 589, 590, 592, 595, 597, 605, 608, 609, 610, 611, 612, 613, 615, 621, 623, 624, 625, 626, 627, 628, 630, 632, 633, 634, 637, 638, 640, 641, 643, 645, 648, 650, 651, 654, 657, 658, 659, 662, 663, 664, 665, 666, 668, 669, 671, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 695, 696, 697, 698, 699, 701, 702, 703, 710, 712, 714, 715, 717, 719, 720, 721, 723, 726, 727, 733, 734, 735, 739, 740, 741, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 756, 758, 759, 760, 762, 763, 765, 767, 768, 773, 775, 776, 777, 778, 779, 780, 783, 787, 788, 790, 793, 796, 797, 799, 800, 802, 803, 804, 806, 807, 808, 810, 813, 814, 818, 819, 823, 824, 825, 827, 829, 830, 832, 835, 838, 841, 844, 848, 849, 850, 851, 853, 858, 859, 860, 861, 866, 867, 868, 869, 870, 871, 873, 874, 876, 877, 878, 879, 882, 886, 888, 889, 891, 892, 893, 895, 896, 901, 902, 905, 907, 909, 911, 912, 917, 918, 922, 923, 924, 927, 928, 929, 930, 931, 932, 934, 935, 943, 944, 949, 950, 951, 953, 954, 956, 958, 959, 961, 962, 963, 966, 967, 969, 970, 972, 973, 974, 975, 977, 981, 985, 986, 987, 991, 993, 994, 996, 1000, 1001, 1004, 1005, 1006, 1010, 1012, 1013, 1017, 1019, 1022, 1023, 1025, 1027, 1030, 1031, 1034, 1037, 1038, 1039, 1042, 1043, 1044, 1046, 1047, 1049, 1050, 1051, 1056, 1057, 1058, 1061, 1063, 1064, 1065, 1067, 1068, 1071, 1072, 1076, 1077, 1078, 1080, 1082, 1084, 1086, 1087, 1091, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1115, 1119, 1123, 1124, 1128, 1131, 1135, 1136, 1137 ] }
car_retails
How many customers have a credit limit of not more than 100,000 and which customer made the highest total payment amount for the year 2004?
creditLimit < = 100000; total payment amount refers to amount; highest total payment amount refers to MAX(amount); year(paymentDate) = '2004';
SELECT ( SELECT COUNT(customerNumber) FROM customers WHERE creditLimit <= 100000 AND customerNumber IN ( SELECT customerNumber FROM payments WHERE STRFTIME('%Y', paymentDate) = '2004' ) ), T1.customerName FROM customers AS T1 INNER JOIN payments AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.creditLimit <= 100000 AND STRFTIME('%Y', T2.paymentDate) = '2004' GROUP BY T1.customerNumber, T1.customerName ORDER BY SUM(T2.amount) DESC LIMIT 1
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,554
1,554
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, customerName TEXT not null, creditLimit REAL ) CREATE TABLE `payments` ( customerNumber INTEGER not null, paymentDate DATE not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "GROUP BY", "AS", "AND", "SELECT", "SUM", "ORDER BY", "LIMIT", "INNER JOIN", "IN", "ON", "DESC", "STRFTIME", "COUNT", "FROM" ]
21
challenging
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 379, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 11, 20, 22, 29, 36, 49, 51, 55, 59, 62, 69, 73, 75, 86, 89, 93, 96, 113, 115, 119, 121, 125, 138, 140, 142, 143, 159, 162, 163, 167, 169, 173, 179, 184, 187, 188, 191, 197, 199, 200, 202, 206, 213, 214, 219, 229, 233, 247, 262, 275, 276, 278, 281, 286, 309, 311, 313, 314, 317, 319, 320, 324, 329, 334, 336, 341, 345, 349, 356, 359, 364, 365, 373, 378, 379, 381, 383, 385, 394, 395, 403, 409, 411, 424, 428, 429, 434, 435, 444, 445, 448, 451, 454, 460, 462, 469, 476, 482, 495, 497, 500, 505, 530, 532, 536, 537, 538, 542, 548, 552, 560, 563, 566, 567, 578, 579, 581, 584, 586, 590, 592, 595, 611, 621, 625, 626, 630, 634, 637, 638, 645, 654, 657, 659, 663, 665, 669, 681, 688, 690, 691, 701, 719, 733, 735, 740, 743, 752, 753, 759, 760, 768, 778, 790, 800, 810, 818, 823, 825, 827, 830, 851, 861, 866, 870, 874, 876, 886, 889, 893, 896, 901, 911, 918, 924, 927, 929, 934, 950, 951, 954, 956, 958, 962, 963, 966, 967, 970, 973, 975, 977, 981, 994, 1005, 1006, 1010, 1013, 1017, 1023, 1025, 1034, 1037, 1038, 1047, 1049, 1050, 1051, 1056, 1064, 1067, 1068, 1094, 1100, 1124, 1135, 1137 ] }
car_retails
Which of the customers, whose Tokyo-based sales representative reports to the Vice President of Sales whose employee number is 1056, has paid the highest payment? List the customer's name, the contact person and calculate the total amount of that customer's total payments.
Tokyo is a city; 'reportsTO' is the leader of the 'employeeNumber'; highest payment refers to MAX(amount); total amount of payments = SUM(amount);
SELECT T2.customerName, T2.contactFirstName, T2.contactLastName, SUM(T3.amount) FROM employees AS T1 INNER JOIN customers AS T2 ON T2.salesRepEmployeeNumber = T1.employeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber INNER JOIN offices AS T4 ON T1.officeCode = T4.officeCode WHERE T4.city = 'Tokyo' AND T1.reportsTo = 1056 GROUP BY T2.customerName, T2.contactFirstName, T2.contactLastName ORDER BY amount DESC LIMIT 1
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,555
1,555
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, officeCode TEXT not null, reportsTo INTEGER, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, city TEXT not null, salesRepEmployeeNumber INTEGER, foreign key salesRepEmployeeNumber references employeesemployeeNumber ) CREATE TABLE `payments` ( customerNumber INTEGER not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "GROUP BY", "AS", "AND", "SELECT", "SUM", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
18
challenging
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 379, 470, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 4, 5, 6, 8, 10, 11, 12, 13, 15, 19, 20, 21, 22, 24, 26, 28, 29, 30, 33, 36, 37, 38, 39, 42, 44, 45, 47, 49, 51, 52, 53, 55, 57, 59, 62, 63, 64, 66, 68, 69, 71, 73, 74, 75, 76, 77, 78, 81, 83, 85, 86, 88, 89, 90, 93, 94, 95, 96, 98, 99, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 148, 150, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 167, 169, 170, 172, 173, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 191, 195, 197, 199, 200, 201, 202, 206, 207, 212, 213, 214, 219, 225, 226, 227, 228, 229, 233, 234, 236, 239, 240, 244, 247, 248, 252, 254, 256, 258, 261, 262, 264, 265, 266, 267, 268, 272, 275, 276, 277, 278, 279, 281, 282, 285, 286, 296, 300, 301, 304, 309, 311, 313, 314, 315, 316, 317, 319, 320, 323, 324, 325, 329, 330, 334, 335, 336, 339, 341, 342, 344, 345, 347, 348, 349, 352, 353, 356, 359, 360, 361, 363, 364, 365, 368, 370, 371, 373, 374, 376, 378, 379, 381, 382, 383, 385, 391, 393, 394, 395, 398, 402, 403, 405, 406, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 424, 425, 426, 427, 428, 429, 433, 434, 435, 436, 437, 438, 440, 444, 445, 446, 448, 450, 451, 452, 454, 455, 460, 462, 463, 464, 469, 470, 473, 475, 476, 477, 480, 482, 483, 486, 487, 488, 490, 493, 494, 495, 496, 497, 498, 500, 505, 507, 514, 515, 516, 518, 519, 520, 522, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 557, 558, 559, 560, 561, 562, 563, 564, 566, 567, 571, 575, 578, 579, 580, 581, 582, 584, 586, 588, 589, 590, 592, 595, 597, 605, 608, 609, 610, 611, 612, 613, 615, 621, 623, 624, 625, 626, 627, 628, 630, 632, 633, 634, 637, 638, 640, 641, 643, 645, 648, 650, 651, 654, 657, 658, 659, 662, 663, 664, 665, 666, 668, 669, 671, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 695, 696, 697, 698, 699, 701, 702, 703, 710, 712, 714, 715, 717, 719, 720, 721, 723, 726, 727, 733, 734, 735, 739, 740, 741, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 756, 758, 759, 760, 762, 763, 765, 767, 768, 773, 775, 776, 777, 778, 779, 780, 783, 787, 788, 790, 793, 796, 797, 799, 800, 802, 803, 804, 806, 807, 808, 810, 813, 814, 818, 819, 823, 824, 825, 827, 829, 830, 832, 835, 838, 841, 844, 848, 849, 850, 851, 853, 858, 859, 860, 861, 866, 867, 868, 869, 870, 871, 873, 874, 876, 877, 878, 879, 882, 886, 888, 889, 891, 892, 893, 895, 896, 901, 902, 905, 907, 909, 911, 912, 917, 918, 922, 923, 924, 927, 928, 929, 930, 931, 932, 934, 935, 943, 944, 949, 950, 951, 953, 954, 956, 958, 959, 961, 962, 963, 966, 967, 969, 970, 972, 973, 974, 975, 977, 981, 985, 986, 987, 991, 993, 994, 996, 1000, 1001, 1004, 1005, 1006, 1010, 1012, 1013, 1017, 1019, 1022, 1023, 1025, 1027, 1030, 1031, 1034, 1037, 1038, 1039, 1042, 1043, 1044, 1046, 1047, 1049, 1050, 1051, 1056, 1057, 1058, 1061, 1063, 1064, 1065, 1067, 1068, 1071, 1072, 1076, 1077, 1078, 1080, 1082, 1084, 1086, 1087, 1091, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1115, 1119, 1123, 1124, 1128, 1131, 1135, 1136, 1137 ] }
car_retails
Which two products has the highest and lowest expected profits? Determine the total price for each product in terms of the largest quantity that was ordered.
expected profits = SUBTRACT(msrp, buyPrice); total price = MULTIPLY(quantityOrdered, priceEach)
SELECT T2.productName, SUM(T1.quantityOrdered * T1.priceEach) FROM orderdetails AS T1 INNER JOIN ( SELECT productCode, productName FROM products ORDER BY MSRP - buyPrice DESC LIMIT 1 ) AS T2 ON T1.productCode = T2.productCode UNION SELECT T2.productName, SUM(quantityOrdered * priceEach) FROM orderdetails AS T1 INNER JOIN ( SELECT productCode, productName FROM products ORDER BY MSRP - buyPrice ASC LIMIT 1 ) AS T2 ON T1.productCode = T2.productCode
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,556
1,556
CREATE TABLE `products` ( productCode TEXT not null primary key, productName TEXT not null, buyPrice REAL not null, MSRP REAL not null ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, productCode )
[ "AS", "SELECT", "SUM", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "ASC", "DESC", "UNION", "FROM" ]
25
challenging
{ "case_1": [ -1 ], "case_2": [ 1038 ], "case_3": [ 379, 470, 609, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 6, 10, 11, 20, 24, 28, 29, 36, 39, 42, 49, 55, 59, 62, 64, 69, 71, 73, 75, 77, 81, 83, 86, 89, 93, 94, 112, 113, 120, 121, 125, 127, 129, 138, 141, 148, 150, 153, 155, 159, 162, 163, 167, 169, 173, 179, 184, 186, 187, 188, 189, 191, 195, 199, 200, 201, 202, 206, 207, 212, 213, 219, 225, 226, 228, 229, 233, 234, 236, 239, 247, 248, 254, 261, 262, 264, 275, 278, 279, 281, 285, 286, 300, 304, 309, 311, 313, 314, 316, 317, 319, 320, 323, 324, 329, 334, 335, 336, 341, 342, 345, 347, 349, 353, 356, 360, 363, 364, 365, 373, 378, 379, 381, 383, 385, 394, 395, 402, 403, 409, 411, 412, 415, 427, 428, 429, 434, 435, 438, 444, 445, 448, 450, 451, 452, 454, 460, 462, 469, 470, 476, 482, 483, 486, 487, 488, 495, 497, 500, 505, 518, 530, 532, 535, 536, 537, 538, 540, 542, 547, 548, 550, 552, 560, 563, 564, 566, 567, 571, 575, 578, 579, 580, 581, 584, 586, 590, 592, 595, 597, 609, 611, 612, 621, 623, 625, 626, 628, 630, 634, 637, 638, 640, 645, 650, 654, 657, 658, 659, 662, 665, 666, 669, 676, 681, 682, 686, 688, 690, 691, 695, 701, 710, 717, 723, 733, 735, 740, 744, 745, 747, 750, 752, 753, 759, 760, 762, 768, 776, 777, 778, 787, 788, 790, 796, 800, 802, 803, 808, 810, 813, 818, 823, 825, 827, 830, 832, 841, 848, 850, 851, 861, 866, 868, 870, 871, 874, 876, 886, 889, 891, 893, 896, 901, 909, 911, 912, 918, 922, 924, 927, 929, 934, 943, 944, 950, 951, 953, 954, 956, 958, 959, 962, 963, 966, 967, 970, 973, 975, 977, 981, 987, 994, 1004, 1005, 1006, 1010, 1012, 1013, 1017, 1023, 1025, 1027, 1031, 1034, 1037, 1038, 1047, 1049, 1050, 1051, 1056, 1064, 1065, 1067, 1068, 1078, 1082, 1087, 1092, 1094, 1098, 1100, 1124, 1135, 1137 ] }
car_retails
How many different orders with a total price greater than 4000 are cancelled?
total price = MULTIPLY(quantityOrdered, priceEach) > 4000; cancelled orders refer to status = 'Cancelled';
SELECT COUNT(DISTINCT T1.orderNumber) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.quantityOrdered * T1.priceEach > 4000 AND T2.status = 'Cancelled'
CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,557
1,557
CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, status TEXT not null ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, quantityOrdered INTEGER not null, priceEach REAL not null, primary key orderNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
8
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 730, 798, 843, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 554, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 618, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 692, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 707, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 730, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 820, 822, 823, 824, 825, 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, 838, 839, 841, 843, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 903, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 945, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1079, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1126, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many distinct orders were there in 2003 when the quantity ordered was less than 30?
year(orderDate) = '2003'; quantityOrdered < 30;
SELECT COUNT(DISTINCT T1.orderNumber) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.quantityOrdered < 30 AND STRFTIME('%Y', T2.orderDate) = '2003'
CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,558
1,558
CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, orderDate DATE not null ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, quantityOrdered INTEGER not null, primary key orderNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "STRFTIME", "COUNT", "FROM" ]
9
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 718, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
What is the total value of cancelled orders?
total value = SUM(MULTIPLY(quantityOrdered, priceEach)); cancelled orders refers to status = 'Cancelled';
SELECT SUM(T1.quantityOrdered * T1.priceEach) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T2.status = 'Cancelled'
CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,559
1,559
CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, status TEXT not null ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, quantityOrdered INTEGER not null, priceEach REAL not null, primary key orderNumber )
[ "AS", "SELECT", "SUM", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Please calculate the total value of Motorcycles orders.
Motorcycle is a product line; total value = SUM(MULTIPLY(quantityOrdered, priceEach));
SELECT SUM(T1.quantityOrdered * T1.priceEach) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productLine = 'Motorcycles'
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,560
1,560
CREATE TABLE `products` ( productCode TEXT not null primary key, productLine TEXT not null, foreign key productLine references productlinesproductLine ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, productCode )
[ "AS", "SELECT", "SUM", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ -1 ], "case_2": [ 1038 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many Planes orders were there?
Planes is a product line;
SELECT COUNT(T1.productCode) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productLine = 'Planes'
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,561
1,561
CREATE TABLE `products` ( productCode TEXT not null primary key, productLine TEXT not null, foreign key productLine references productlinesproductLine ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, productCode )
[ "AS", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
7
simple
{ "case_1": [ -1 ], "case_2": [ 1038 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many orders which expected profits greater than 100?
expected profits greater than 100 = (SUBTRACT(msrp, buyPrice))>100;
SELECT COUNT(T1.productCode) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.MSRP - T2.buyPrice > 100
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,562
1,562
CREATE TABLE `products` ( productCode TEXT not null primary key, buyPrice REAL not null, MSRP REAL not null ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, productCode )
[ "AS", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
7
simple
{ "case_1": [ -1 ], "case_2": [ 1038 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Please calculate the average total price of orders from Exoto Designs Vendor in 2005.
average total price = DIVIDE(SUM(MULTIPLY(quantityOrdered, priceEach))), COUNT(orderNumber)); year(orderDate) = '2005';
SELECT SUM(T2.quantityOrdered * T2.priceEach) / COUNT(T3.orderNumber) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber WHERE T1.productVendor = 'Exoto Designs' AND STRFTIME('%Y', T3.orderDate) = '2005'
CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,563
1,563
CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, orderDate DATE not null ) CREATE TABLE `products` ( productCode TEXT not null primary key, productVendor TEXT not null ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, primary key orderNumber, productCode )
[ "AS", "AND", "SELECT", "SUM", "INNER JOIN", "ON", "STRFTIME", "COUNT", "FROM" ]
13
medium
{ "case_1": [ -1 ], "case_2": [ 379 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 718, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many sales representatives who have office code is 1?
sales representative refers to jobTitle = 'Sales Rep';
SELECT COUNT(officeCode) FROM employees WHERE jobTitle = 'Sales Rep' AND officeCode = 1
CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,564
1,564
CREATE TABLE `employees` ( officeCode TEXT not null, jobTitle TEXT not null, foreign key officeCode references officesofficeCode )
[ "COUNT", "AND", "SELECT", "FROM" ]
4
simple
{ "case_1": [ 843 ], "case_2": [ 843 ], "case_3": [ 8, 16, 168, 470, 648, 718, 730, 798, 843, 864 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 19, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 35, 36, 37, 38, 39, 40, 43, 44, 45, 47, 50, 51, 52, 53, 55, 56, 57, 61, 62, 63, 66, 67, 68, 69, 71, 73, 74, 75, 76, 77, 78, 79, 82, 85, 86, 87, 88, 89, 90, 91, 93, 95, 96, 98, 99, 100, 106, 108, 109, 111, 112, 113, 115, 116, 117, 118, 119, 121, 124, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 147, 148, 152, 154, 157, 158, 159, 160, 163, 164, 167, 168, 169, 170, 172, 173, 175, 176, 177, 179, 180, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 196, 197, 198, 199, 200, 202, 203, 206, 210, 212, 214, 216, 219, 223, 224, 225, 226, 227, 229, 230, 233, 234, 239, 240, 243, 244, 247, 252, 254, 255, 256, 258, 259, 261, 262, 265, 266, 267, 268, 269, 270, 271, 272, 273, 275, 276, 277, 278, 282, 286, 291, 293, 294, 296, 299, 301, 303, 305, 311, 314, 315, 316, 317, 319, 320, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 348, 349, 350, 352, 354, 356, 358, 359, 360, 361, 362, 364, 367, 368, 370, 371, 373, 374, 375, 376, 380, 382, 383, 384, 385, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 423, 424, 425, 426, 427, 428, 433, 436, 437, 438, 439, 440, 443, 444, 445, 446, 447, 448, 451, 452, 453, 454, 455, 458, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 473, 475, 476, 477, 478, 480, 481, 482, 484, 485, 487, 488, 490, 492, 493, 494, 496, 497, 498, 500, 504, 505, 507, 509, 510, 512, 514, 515, 516, 517, 519, 520, 522, 524, 526, 528, 529, 530, 531, 532, 533, 535, 536, 537, 538, 539, 541, 542, 543, 544, 545, 547, 548, 551, 552, 554, 557, 558, 559, 560, 561, 562, 563, 564, 566, 573, 580, 581, 582, 584, 585, 586, 588, 589, 591, 594, 595, 596, 597, 598, 599, 601, 603, 605, 606, 608, 610, 611, 612, 613, 615, 618, 620, 622, 624, 625, 626, 627, 629, 630, 632, 633, 634, 637, 641, 643, 645, 646, 648, 649, 651, 654, 656, 658, 659, 661, 662, 663, 664, 665, 666, 667, 668, 669, 671, 673, 675, 677, 678, 679, 680, 681, 683, 684, 685, 686, 687, 688, 689, 690, 692, 693, 694, 696, 697, 698, 699, 702, 703, 705, 707, 712, 714, 715, 716, 718, 719, 721, 726, 727, 730, 733, 734, 735, 736, 737, 739, 740, 741, 743, 746, 747, 748, 749, 750, 752, 753, 754, 756, 757, 758, 760, 762, 763, 765, 767, 768, 769, 770, 772, 773, 775, 776, 777, 778, 779, 780, 783, 785, 787, 788, 790, 793, 794, 795, 796, 797, 798, 799, 800, 802, 804, 806, 807, 808, 810, 811, 812, 813, 814, 817, 818, 819, 820, 821, 824, 825, 827, 829, 830, 831, 832, 835, 838, 839, 840, 841, 843, 844, 848, 849, 851, 853, 855, 857, 858, 859, 860, 861, 864, 865, 866, 867, 869, 870, 873, 874, 876, 877, 878, 879, 886, 888, 890, 892, 893, 894, 895, 896, 897, 898, 899, 901, 902, 903, 905, 907, 909, 911, 912, 913, 915, 917, 918, 920, 922, 923, 924, 926, 927, 928, 930, 931, 932, 934, 935, 941, 942, 943, 944, 945, 949, 950, 951, 953, 954, 956, 958, 960, 961, 963, 965, 968, 969, 972, 974, 975, 976, 977, 981, 983, 985, 986, 991, 993, 996, 998, 1000, 1001, 1005, 1006, 1008, 1009, 1010, 1011, 1013, 1014, 1015, 1017, 1018, 1019, 1020, 1022, 1023, 1027, 1030, 1031, 1037, 1039, 1042, 1043, 1044, 1046, 1047, 1050, 1051, 1053, 1055, 1057, 1058, 1059, 1061, 1062, 1063, 1064, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1084, 1086, 1087, 1090, 1092, 1094, 1096, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1112, 1113, 1115, 1117, 1119, 1121, 1123, 1124, 1126, 1127, 1128, 1131, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Please list different customer names with the payment amount of over 50,000.
amount > 50000;
SELECT DISTINCT T2.customerName FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.amount > 50000
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,565
1,565
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, customerName TEXT not null ) CREATE TABLE `payments` ( customerNumber INTEGER not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 523, 609 ], "case_2": [ 523, 609 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Please calculate the total payment amount of customers who come from the USA.
USA is a country; total amount payment refers to SUM(amount);
SELECT SUM(T1.amount) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.country = 'USA'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,566
1,566
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, country TEXT not null ) CREATE TABLE `payments` ( customerNumber INTEGER not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "SELECT", "SUM", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 523, 609 ], "case_2": [ 523, 609 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
What are the total payments of customers with no credit limit in 2003?
total payment refers to SUM(amount); no credit limit refers to creditLimit = 0; year(paymentDate) = '2003';
SELECT SUM(amount) FROM payments WHERE STRFTIME('%Y', paymentDate) = '2003' AND customerNumber IN ( SELECT customerNumber FROM customers WHERE creditLimit = 0 )
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,567
1,567
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, creditLimit REAL ) CREATE TABLE `payments` ( customerNumber INTEGER not null, paymentDate DATE not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "AND", "SELECT", "SUM", "IN", "STRFTIME", "FROM" ]
8
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 379, 470, 718, 798 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 22, 24, 39, 51, 71, 73, 93, 96, 109, 112, 113, 119, 127, 129, 141, 169, 184, 197, 200, 207, 214, 219, 223, 270, 276, 317, 341, 350, 356, 379, 383, 393, 399, 402, 427, 438, 448, 452, 470, 476, 500, 510, 514, 537, 563, 581, 612, 630, 663, 666, 686, 690, 718, 740, 747, 753, 776, 777, 788, 798, 800, 808, 810, 817, 825, 832, 848, 851, 870, 872, 874, 896, 903, 924, 944, 958, 998, 1001, 1008, 1023, 1027, 1031, 1044, 1064, 1068, 1092, 1100, 1121 ] }
car_retails
Please list the name and phone number of the customer whose order was cancelled.
cancelled order refers to status = 'Cancelled';
SELECT T2.customerName, T2.phone FROM orders AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.status = 'Cancelled'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,568
1,568
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, customerName TEXT not null, phone TEXT not null ) CREATE TABLE `orders` ( status TEXT not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many French customers shipped 2 orders which have been cancelled?
French is a nationality of country = 'France'; cancelled orders refers to status = 'Cancelled';
SELECT COUNT(T2.country) FROM orders AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.status = 'Shipped' AND T2.country = 'France' GROUP BY T2.customerNumber HAVING COUNT(T1.status) = 2
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,569
1,569
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, country TEXT not null ) CREATE TABLE `orders` ( status TEXT not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber )
[ "GROUP BY", "AS", "AND", "SELECT", "HAVING", "INNER JOIN", "ON", "COUNT", "FROM" ]
11
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 182, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Please calculate the average total price of shipped orders from German customers.
average total price = DIVIDE(MULTIPLY(quantityOrdered, priceEach)), COUNT(orderNumber)); German is a nationality of country = 'Germany'; shipped orders refers to status = 'Shipped';
SELECT SUM(T3.quantityOrdered * T3.priceEach) / COUNT(T2.orderNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber INNER JOIN orderdetails AS T3 ON T2.orderNumber = T3.orderNumber WHERE T2.status = 'Shipped' AND T1.country = 'Germany'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,570
1,570
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, country TEXT not null ) CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, status TEXT not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, quantityOrdered INTEGER not null, priceEach REAL not null, primary key orderNumber )
[ "AS", "AND", "SELECT", "SUM", "INNER JOIN", "ON", "COUNT", "FROM" ]
12
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
List out full name of employees who are working in Tokyo?
Tokyo is a city; full name = firstName+lastName;
SELECT T1.firstName, T1.lastName FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Tokyo'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,571
1,571
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( lastName TEXT not null, firstName TEXT not null, officeCode TEXT not null, foreign key officeCode references officesofficeCode )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many Sales Rep who are working in Tokyo? List out email and full name of those employees.
Sales Rep is a job title; Tokyo is a city; full name = firstName+lastName;
SELECT T1.firstName, T1.lastName, T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Tokyo' AND T1.jobTitle = 'Sales Rep'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,572
1,572
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( lastName TEXT not null, firstName TEXT not null, email TEXT not null, officeCode TEXT not null, jobTitle TEXT not null, foreign key officeCode references officesofficeCode )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
State the email of those who are staff of Murphy Diane whose number is 1002 and living in San Francisco
staff of refers to reportsTO; San Francisco is a city;
SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1002 AND T2.city = 'San Francisco'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,573
1,573
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Determine the email and Code of employee who are working at United State, state MA
code of employee refers to employeeNumber; United States of America refers to country = 'USA';
SELECT T1.email, T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.state = 'MA' AND T2.country = 'USA'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,574
1,574
CREATE TABLE `offices` ( officeCode TEXT not null primary key, state TEXT, country TEXT not null ) CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, email TEXT not null, officeCode TEXT not null, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
7
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many Sales Manager who are working in Sydney? List out their email.
Sales Manager is a job title; Sydney is a city;
SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.jobTitle LIKE '%Sales Manager%' AND T2.city = 'Sydney'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,575
1,575
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( email TEXT not null, officeCode TEXT not null, jobTitle TEXT not null, foreign key officeCode references officesofficeCode )
[ "AS", "AND", "SELECT", "LIKE", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 168, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1018, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1117, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many employees who are living in Australia and have the credit limit under 200000? State their email address and countries where they are working.
Australia is a country; creditLimit < 20000;
SELECT T2.email, T3.country FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber INNER JOIN offices AS T3 ON T2.officeCode = T3.officeCode WHERE T3.country = 'Australia' AND T1.creditLimit < 200000 AND T2.jobTitle = 'Sales Rep'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,576
1,576
CREATE TABLE `offices` ( officeCode TEXT not null primary key, country TEXT not null ) CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, email TEXT not null, officeCode TEXT not null, jobTitle TEXT not null, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key salesRepEmployeeNumber references employeesemployeeNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
11
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
State 10 emails of UK Sales Rep who have the lowest credit limit.
UK is a country; Sales Rep is a job title;
SELECT DISTINCT T2.email FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' AND T1.country = 'UK' ORDER BY T1.creditLimit LIMIT 10
CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,577
1,577
CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, email TEXT not null, jobTitle TEXT not null, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key salesRepEmployeeNumber references employeesemployeeNumber )
[ "AS", "AND", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "FROM" ]
9
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
How many Australian customers who have credit line under 220000?
Australian is a nationality of country = 'Australia'; credit line refers to creditLimit; creditLimit < 220000;
SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND country = 'Australia'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,578
1,578
CREATE TABLE `customers` ( country TEXT not null, creditLimit REAL )
[ "COUNT", "AND", "SELECT", "FROM" ]
4
simple
{ "case_1": [ 168, 730 ], "case_2": [ 168, 730 ], "case_3": [ 8, 16, 168, 470, 648, 718, 730, 798, 843, 864 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 19, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 35, 36, 37, 38, 39, 40, 43, 44, 45, 47, 50, 51, 52, 53, 55, 56, 57, 61, 62, 63, 66, 67, 68, 69, 71, 73, 74, 75, 76, 77, 78, 79, 82, 85, 86, 87, 88, 89, 90, 91, 93, 95, 96, 98, 99, 100, 106, 108, 109, 111, 112, 113, 115, 116, 117, 118, 119, 121, 124, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 147, 148, 152, 154, 157, 158, 159, 160, 163, 164, 167, 168, 169, 170, 172, 173, 175, 176, 177, 179, 180, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 196, 197, 198, 199, 200, 202, 203, 206, 210, 212, 214, 216, 219, 223, 224, 225, 226, 227, 229, 230, 233, 234, 239, 240, 243, 244, 247, 252, 254, 255, 256, 258, 259, 261, 262, 265, 266, 267, 268, 269, 270, 271, 272, 273, 275, 276, 277, 278, 282, 286, 291, 293, 294, 296, 299, 301, 303, 305, 311, 314, 315, 316, 317, 319, 320, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 348, 349, 350, 352, 354, 356, 358, 359, 360, 361, 362, 364, 367, 368, 370, 371, 373, 374, 375, 376, 380, 382, 383, 384, 385, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 423, 424, 425, 426, 427, 428, 433, 436, 437, 438, 439, 440, 443, 444, 445, 446, 447, 448, 451, 452, 453, 454, 455, 458, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 473, 475, 476, 477, 478, 480, 481, 482, 484, 485, 487, 488, 490, 492, 493, 494, 496, 497, 498, 500, 504, 505, 507, 509, 510, 512, 514, 515, 516, 517, 519, 520, 522, 524, 526, 528, 529, 530, 531, 532, 533, 535, 536, 537, 538, 539, 541, 542, 543, 544, 545, 547, 548, 551, 552, 554, 557, 558, 559, 560, 561, 562, 563, 564, 566, 573, 580, 581, 582, 584, 585, 586, 588, 589, 591, 594, 595, 596, 597, 598, 599, 601, 603, 605, 606, 608, 610, 611, 612, 613, 615, 618, 620, 622, 624, 625, 626, 627, 629, 630, 632, 633, 634, 637, 641, 643, 645, 646, 648, 649, 651, 654, 656, 658, 659, 661, 662, 663, 664, 665, 666, 667, 668, 669, 671, 673, 675, 677, 678, 679, 680, 681, 683, 684, 685, 686, 687, 688, 689, 690, 692, 693, 694, 696, 697, 698, 699, 702, 703, 705, 707, 712, 714, 715, 716, 718, 719, 721, 726, 727, 730, 733, 734, 735, 736, 737, 739, 740, 741, 743, 746, 747, 748, 749, 750, 752, 753, 754, 756, 757, 758, 760, 762, 763, 765, 767, 768, 769, 770, 772, 773, 775, 776, 777, 778, 779, 780, 783, 785, 787, 788, 790, 793, 794, 795, 796, 797, 798, 799, 800, 802, 804, 806, 807, 808, 810, 811, 812, 813, 814, 817, 818, 819, 820, 821, 824, 825, 827, 829, 830, 831, 832, 835, 838, 839, 840, 841, 843, 844, 848, 849, 851, 853, 855, 857, 858, 859, 860, 861, 864, 865, 866, 867, 869, 870, 873, 874, 876, 877, 878, 879, 886, 888, 890, 892, 893, 894, 895, 896, 897, 898, 899, 901, 902, 903, 905, 907, 909, 911, 912, 913, 915, 917, 918, 920, 922, 923, 924, 926, 927, 928, 930, 931, 932, 934, 935, 941, 942, 943, 944, 945, 949, 950, 951, 953, 954, 956, 958, 960, 961, 963, 965, 968, 969, 972, 974, 975, 976, 977, 981, 983, 985, 986, 991, 993, 996, 998, 1000, 1001, 1005, 1006, 1008, 1009, 1010, 1011, 1013, 1014, 1015, 1017, 1018, 1019, 1020, 1022, 1023, 1027, 1030, 1031, 1037, 1039, 1042, 1043, 1044, 1046, 1047, 1050, 1051, 1053, 1055, 1057, 1058, 1059, 1061, 1062, 1063, 1064, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1084, 1086, 1087, 1090, 1092, 1094, 1096, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1112, 1113, 1115, 1117, 1119, 1121, 1123, 1124, 1126, 1127, 1128, 1131, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
List out 3 customer numbers who have highest amount payment
amount of payment refers to amount;
SELECT customerNumber FROM payments ORDER BY amount DESC LIMIT 3
CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,579
1,579
CREATE TABLE `payments` ( customerNumber INTEGER not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "SELECT", "ORDER BY", "LIMIT", "FROM", "DESC" ]
5
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 379, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 10, 11, 13, 15, 17, 20, 28, 29, 36, 38, 43, 49, 55, 59, 62, 69, 73, 75, 78, 86, 89, 108, 110, 121, 125, 133, 138, 150, 159, 162, 163, 167, 173, 174, 179, 181, 185, 187, 188, 199, 200, 202, 206, 208, 213, 229, 233, 239, 247, 252, 262, 263, 275, 278, 281, 285, 286, 291, 309, 311, 313, 314, 319, 320, 324, 328, 329, 334, 336, 337, 341, 342, 345, 348, 349, 352, 353, 356, 359, 364, 365, 371, 373, 378, 379, 381, 385, 394, 395, 400, 403, 404, 409, 411, 428, 429, 434, 435, 444, 445, 451, 454, 460, 462, 469, 482, 495, 497, 505, 530, 532, 534, 536, 538, 542, 548, 552, 555, 560, 566, 567, 576, 578, 579, 583, 584, 586, 590, 592, 595, 611, 619, 621, 625, 626, 634, 637, 638, 645, 654, 657, 659, 664, 665, 669, 681, 688, 690, 691, 698, 701, 703, 708, 713, 719, 732, 733, 735, 748, 752, 759, 760, 768, 778, 790, 803, 810, 815, 818, 823, 827, 830, 836, 850, 851, 861, 866, 869, 876, 886, 889, 891, 893, 901, 911, 918, 927, 929, 934, 946, 950, 951, 953, 954, 956, 962, 963, 966, 967, 970, 972, 973, 975, 977, 981, 983, 987, 989, 994, 1004, 1005, 1006, 1010, 1013, 1017, 1024, 1025, 1030, 1034, 1037, 1038, 1047, 1049, 1050, 1051, 1056, 1057, 1065, 1067, 1068, 1075, 1076, 1077, 1083, 1094, 1124, 1137, 1139, 1141 ] }
car_retails
Determine the email and Code of employee who are working at United State, state CA
United States of America refers to country = 'USA'; code of employee refers to employeeNumber;
SELECT T1.email, T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.country = 'USA' AND T2.state = 'CA' GROUP BY T1.email, T1.officeCode
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,580
1,580
CREATE TABLE `offices` ( officeCode TEXT not null primary key, state TEXT, country TEXT not null ) CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, email TEXT not null, officeCode TEXT not null, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber )
[ "GROUP BY", "AS", "AND", "SELECT", "INNER JOIN", "ON", "FROM" ]
8
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 551, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
List out full name of employees who are working in Boston?
full name = contactFirstName, contactLastName; Boston is a city;
SELECT T1.firstName, T1.lastName FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Boston'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,581
1,581
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( lastName TEXT not null, firstName TEXT not null, officeCode TEXT not null, foreign key officeCode references officesofficeCode )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
State top 3 emails of UK Sales Rep who have the highest credit limit.
UK is a country; Sales Rep is a job title;
SELECT T2.email FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' AND T1.country = 'UK' GROUP BY T1.customerName, T2.email ORDER BY SUM(T1.creditLimit) DESC LIMIT 3
CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,582
1,582
CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, email TEXT not null, jobTitle TEXT not null, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( customerName TEXT not null, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key salesRepEmployeeNumber references employeesemployeeNumber )
[ "GROUP BY", "AS", "AND", "SELECT", "SUM", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
12
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 379, 470, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 4, 5, 6, 8, 10, 11, 12, 13, 15, 19, 20, 21, 22, 24, 26, 28, 29, 30, 33, 36, 37, 38, 39, 42, 44, 45, 47, 49, 51, 52, 53, 55, 57, 59, 62, 63, 64, 66, 68, 69, 71, 73, 74, 75, 76, 77, 78, 81, 83, 85, 86, 88, 89, 90, 93, 94, 95, 96, 98, 99, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 148, 150, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 167, 169, 170, 172, 173, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 191, 195, 197, 199, 200, 201, 202, 206, 207, 212, 213, 214, 219, 225, 226, 227, 228, 229, 233, 234, 236, 239, 240, 244, 247, 248, 252, 254, 256, 258, 261, 262, 264, 265, 266, 267, 268, 272, 275, 276, 277, 278, 279, 281, 282, 285, 286, 296, 300, 301, 304, 309, 311, 313, 314, 315, 316, 317, 319, 320, 323, 324, 325, 329, 330, 334, 335, 336, 339, 341, 342, 344, 345, 347, 348, 349, 352, 353, 356, 359, 360, 361, 363, 364, 365, 368, 370, 371, 373, 374, 376, 378, 379, 381, 382, 383, 385, 391, 393, 394, 395, 398, 402, 403, 405, 406, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 424, 425, 426, 427, 428, 429, 433, 434, 435, 436, 437, 438, 440, 444, 445, 446, 448, 450, 451, 452, 454, 455, 460, 462, 463, 464, 469, 470, 473, 475, 476, 477, 480, 482, 483, 486, 487, 488, 490, 493, 494, 495, 496, 497, 498, 500, 505, 507, 514, 515, 516, 518, 519, 520, 522, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 557, 558, 559, 560, 561, 562, 563, 564, 566, 567, 571, 575, 578, 579, 580, 581, 582, 584, 586, 588, 589, 590, 592, 595, 597, 605, 608, 609, 610, 611, 612, 613, 615, 621, 623, 624, 625, 626, 627, 628, 630, 632, 633, 634, 637, 638, 640, 641, 643, 645, 648, 650, 651, 654, 657, 658, 659, 662, 663, 664, 665, 666, 668, 669, 671, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 695, 696, 697, 698, 699, 701, 702, 703, 710, 712, 714, 715, 717, 719, 720, 721, 723, 726, 727, 733, 734, 735, 739, 740, 741, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 756, 758, 759, 760, 762, 763, 765, 767, 768, 773, 775, 776, 777, 778, 779, 780, 783, 787, 788, 790, 793, 796, 797, 799, 800, 802, 803, 804, 806, 807, 808, 810, 813, 814, 818, 819, 823, 824, 825, 827, 829, 830, 832, 835, 838, 841, 844, 848, 849, 850, 851, 853, 858, 859, 860, 861, 866, 867, 868, 869, 870, 871, 873, 874, 876, 877, 878, 879, 882, 886, 888, 889, 891, 892, 893, 895, 896, 901, 902, 905, 907, 909, 911, 912, 917, 918, 922, 923, 924, 927, 928, 929, 930, 931, 932, 934, 935, 943, 944, 949, 950, 951, 953, 954, 956, 958, 959, 961, 962, 963, 966, 967, 969, 970, 972, 973, 974, 975, 977, 981, 985, 986, 987, 991, 993, 994, 996, 1000, 1001, 1004, 1005, 1006, 1010, 1012, 1013, 1017, 1019, 1022, 1023, 1025, 1027, 1030, 1031, 1034, 1037, 1038, 1039, 1042, 1043, 1044, 1046, 1047, 1049, 1050, 1051, 1056, 1057, 1058, 1061, 1063, 1064, 1065, 1067, 1068, 1071, 1072, 1076, 1077, 1078, 1080, 1082, 1084, 1086, 1087, 1091, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1115, 1119, 1123, 1124, 1128, 1131, 1135, 1136, 1137 ] }
car_retails
How many customers who are in Norway and have credit line under 220000?
Norway is a country; credit line refers to creditLimit; creditLimit<220000;
SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND country = 'Norway'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,583
1,583
CREATE TABLE `customers` ( country TEXT not null, creditLimit REAL )
[ "COUNT", "AND", "SELECT", "FROM" ]
4
simple
{ "case_1": [ 168, 730 ], "case_2": [ 168, 730 ], "case_3": [ 8, 16, 168, 470, 648, 718, 730, 798, 843, 864 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 19, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 35, 36, 37, 38, 39, 40, 43, 44, 45, 47, 50, 51, 52, 53, 55, 56, 57, 61, 62, 63, 66, 67, 68, 69, 71, 73, 74, 75, 76, 77, 78, 79, 82, 85, 86, 87, 88, 89, 90, 91, 93, 95, 96, 98, 99, 100, 106, 108, 109, 111, 112, 113, 115, 116, 117, 118, 119, 121, 124, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 147, 148, 152, 154, 157, 158, 159, 160, 163, 164, 167, 168, 169, 170, 172, 173, 175, 176, 177, 179, 180, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 196, 197, 198, 199, 200, 202, 203, 206, 210, 212, 214, 216, 219, 223, 224, 225, 226, 227, 229, 230, 233, 234, 239, 240, 243, 244, 247, 252, 254, 255, 256, 258, 259, 261, 262, 265, 266, 267, 268, 269, 270, 271, 272, 273, 275, 276, 277, 278, 282, 286, 291, 293, 294, 296, 299, 301, 303, 305, 311, 314, 315, 316, 317, 319, 320, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 348, 349, 350, 352, 354, 356, 358, 359, 360, 361, 362, 364, 367, 368, 370, 371, 373, 374, 375, 376, 380, 382, 383, 384, 385, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 423, 424, 425, 426, 427, 428, 433, 436, 437, 438, 439, 440, 443, 444, 445, 446, 447, 448, 451, 452, 453, 454, 455, 458, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 473, 475, 476, 477, 478, 480, 481, 482, 484, 485, 487, 488, 490, 492, 493, 494, 496, 497, 498, 500, 504, 505, 507, 509, 510, 512, 514, 515, 516, 517, 519, 520, 522, 524, 526, 528, 529, 530, 531, 532, 533, 535, 536, 537, 538, 539, 541, 542, 543, 544, 545, 547, 548, 551, 552, 554, 557, 558, 559, 560, 561, 562, 563, 564, 566, 573, 580, 581, 582, 584, 585, 586, 588, 589, 591, 594, 595, 596, 597, 598, 599, 601, 603, 605, 606, 608, 610, 611, 612, 613, 615, 618, 620, 622, 624, 625, 626, 627, 629, 630, 632, 633, 634, 637, 641, 643, 645, 646, 648, 649, 651, 654, 656, 658, 659, 661, 662, 663, 664, 665, 666, 667, 668, 669, 671, 673, 675, 677, 678, 679, 680, 681, 683, 684, 685, 686, 687, 688, 689, 690, 692, 693, 694, 696, 697, 698, 699, 702, 703, 705, 707, 712, 714, 715, 716, 718, 719, 721, 726, 727, 730, 733, 734, 735, 736, 737, 739, 740, 741, 743, 746, 747, 748, 749, 750, 752, 753, 754, 756, 757, 758, 760, 762, 763, 765, 767, 768, 769, 770, 772, 773, 775, 776, 777, 778, 779, 780, 783, 785, 787, 788, 790, 793, 794, 795, 796, 797, 798, 799, 800, 802, 804, 806, 807, 808, 810, 811, 812, 813, 814, 817, 818, 819, 820, 821, 824, 825, 827, 829, 830, 831, 832, 835, 838, 839, 840, 841, 843, 844, 848, 849, 851, 853, 855, 857, 858, 859, 860, 861, 864, 865, 866, 867, 869, 870, 873, 874, 876, 877, 878, 879, 886, 888, 890, 892, 893, 894, 895, 896, 897, 898, 899, 901, 902, 903, 905, 907, 909, 911, 912, 913, 915, 917, 918, 920, 922, 923, 924, 926, 927, 928, 930, 931, 932, 934, 935, 941, 942, 943, 944, 945, 949, 950, 951, 953, 954, 956, 958, 960, 961, 963, 965, 968, 969, 972, 974, 975, 976, 977, 981, 983, 985, 986, 991, 993, 996, 998, 1000, 1001, 1005, 1006, 1008, 1009, 1010, 1011, 1013, 1014, 1015, 1017, 1018, 1019, 1020, 1022, 1023, 1027, 1030, 1031, 1037, 1039, 1042, 1043, 1044, 1046, 1047, 1050, 1051, 1053, 1055, 1057, 1058, 1059, 1061, 1062, 1063, 1064, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1084, 1086, 1087, 1090, 1092, 1094, 1096, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1112, 1113, 1115, 1117, 1119, 1121, 1123, 1124, 1126, 1127, 1128, 1131, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
List out full name and email of employees who are working in Paris?
full name = firstName+LastName; Paris is a city;
SELECT T1.firstName, T1.lastName, T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Paris'
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,584
1,584
CREATE TABLE `offices` ( officeCode TEXT not null primary key, city TEXT not null ) CREATE TABLE `employees` ( lastName TEXT not null, firstName TEXT not null, email TEXT not null, officeCode TEXT not null, foreign key officeCode references officesofficeCode )
[ "AS", "SELECT", "INNER JOIN", "ON", "FROM" ]
6
simple
{ "case_1": [ 8, 648 ], "case_2": [ 8, 16, 648 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 508, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 978, 980, 981, 982, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1075, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
List the product code of the top five motorcycles, by descending order, the number of quantity in stock.
motorcycle is a product line;
SELECT productCode, quantityInStock FROM products WHERE productLine = 'Motorcycles' ORDER BY quantityInStock DESC LIMIT 5
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,585
1,585
CREATE TABLE `products` ( productCode TEXT not null primary key, productLine TEXT not null, quantityInStock INTEGER not null, foreign key productLine references productlinesproductLine )
[ "SELECT", "ORDER BY", "LIMIT", "FROM", "DESC" ]
5
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 379, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 10, 11, 13, 15, 17, 20, 28, 29, 36, 38, 43, 49, 55, 59, 62, 69, 73, 75, 78, 86, 89, 108, 110, 121, 125, 133, 138, 150, 159, 162, 163, 167, 173, 174, 179, 181, 185, 187, 188, 199, 200, 202, 206, 208, 213, 229, 233, 239, 247, 252, 262, 263, 275, 278, 281, 285, 286, 291, 309, 311, 313, 314, 319, 320, 324, 328, 329, 334, 336, 337, 341, 342, 345, 348, 349, 352, 353, 356, 359, 364, 365, 371, 373, 378, 379, 381, 385, 394, 395, 400, 403, 404, 409, 411, 428, 429, 434, 435, 444, 445, 451, 454, 460, 462, 469, 482, 495, 497, 505, 530, 532, 534, 536, 538, 542, 548, 552, 555, 560, 566, 567, 576, 578, 579, 583, 584, 586, 590, 592, 595, 611, 619, 621, 625, 626, 634, 637, 638, 645, 654, 657, 659, 664, 665, 669, 681, 688, 690, 691, 698, 701, 703, 708, 713, 719, 732, 733, 735, 748, 752, 759, 760, 768, 778, 790, 803, 810, 815, 818, 823, 827, 830, 836, 850, 851, 861, 866, 869, 876, 886, 889, 891, 893, 901, 911, 918, 927, 929, 934, 946, 950, 951, 953, 954, 956, 962, 963, 966, 967, 970, 972, 973, 975, 977, 981, 983, 987, 989, 994, 1004, 1005, 1006, 1010, 1013, 1017, 1024, 1025, 1030, 1034, 1037, 1038, 1047, 1049, 1050, 1051, 1056, 1057, 1065, 1067, 1068, 1075, 1076, 1077, 1083, 1094, 1124, 1137, 1139, 1141 ] }
car_retails
Among the German customers, how many of the them has credit limit of zero?
German is a nationality of country = 'Germany'; CREDITLIMIT = 0
SELECT COUNT(customerNumber) FROM customers WHERE creditLimit = 0 AND country = 'Germany'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,586
1,586
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, country TEXT not null, creditLimit REAL )
[ "COUNT", "AND", "SELECT", "FROM" ]
4
simple
{ "case_1": [ 168, 730 ], "case_2": [ 168, 730 ], "case_3": [ 8, 16, 168, 470, 648, 718, 730, 798, 843, 864 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 19, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 35, 36, 37, 38, 39, 40, 43, 44, 45, 47, 50, 51, 52, 53, 55, 56, 57, 61, 62, 63, 66, 67, 68, 69, 71, 73, 74, 75, 76, 77, 78, 79, 82, 85, 86, 87, 88, 89, 90, 91, 93, 95, 96, 98, 99, 100, 106, 108, 109, 111, 112, 113, 115, 116, 117, 118, 119, 121, 124, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 147, 148, 152, 154, 157, 158, 159, 160, 163, 164, 167, 168, 169, 170, 172, 173, 175, 176, 177, 179, 180, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 196, 197, 198, 199, 200, 202, 203, 206, 210, 212, 214, 216, 219, 223, 224, 225, 226, 227, 229, 230, 233, 234, 239, 240, 243, 244, 247, 252, 254, 255, 256, 258, 259, 261, 262, 265, 266, 267, 268, 269, 270, 271, 272, 273, 275, 276, 277, 278, 282, 286, 291, 293, 294, 296, 299, 301, 303, 305, 311, 314, 315, 316, 317, 319, 320, 323, 325, 330, 334, 335, 336, 338, 339, 341, 344, 345, 348, 349, 350, 352, 354, 356, 358, 359, 360, 361, 362, 364, 367, 368, 370, 371, 373, 374, 375, 376, 380, 382, 383, 384, 385, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 408, 409, 410, 411, 412, 413, 414, 416, 417, 418, 419, 420, 421, 423, 424, 425, 426, 427, 428, 433, 436, 437, 438, 439, 440, 443, 444, 445, 446, 447, 448, 451, 452, 453, 454, 455, 458, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 473, 475, 476, 477, 478, 480, 481, 482, 484, 485, 487, 488, 490, 492, 493, 494, 496, 497, 498, 500, 504, 505, 507, 509, 510, 512, 514, 515, 516, 517, 519, 520, 522, 524, 526, 528, 529, 530, 531, 532, 533, 535, 536, 537, 538, 539, 541, 542, 543, 544, 545, 547, 548, 551, 552, 554, 557, 558, 559, 560, 561, 562, 563, 564, 566, 573, 580, 581, 582, 584, 585, 586, 588, 589, 591, 594, 595, 596, 597, 598, 599, 601, 603, 605, 606, 608, 610, 611, 612, 613, 615, 618, 620, 622, 624, 625, 626, 627, 629, 630, 632, 633, 634, 637, 641, 643, 645, 646, 648, 649, 651, 654, 656, 658, 659, 661, 662, 663, 664, 665, 666, 667, 668, 669, 671, 673, 675, 677, 678, 679, 680, 681, 683, 684, 685, 686, 687, 688, 689, 690, 692, 693, 694, 696, 697, 698, 699, 702, 703, 705, 707, 712, 714, 715, 716, 718, 719, 721, 726, 727, 730, 733, 734, 735, 736, 737, 739, 740, 741, 743, 746, 747, 748, 749, 750, 752, 753, 754, 756, 757, 758, 760, 762, 763, 765, 767, 768, 769, 770, 772, 773, 775, 776, 777, 778, 779, 780, 783, 785, 787, 788, 790, 793, 794, 795, 796, 797, 798, 799, 800, 802, 804, 806, 807, 808, 810, 811, 812, 813, 814, 817, 818, 819, 820, 821, 824, 825, 827, 829, 830, 831, 832, 835, 838, 839, 840, 841, 843, 844, 848, 849, 851, 853, 855, 857, 858, 859, 860, 861, 864, 865, 866, 867, 869, 870, 873, 874, 876, 877, 878, 879, 886, 888, 890, 892, 893, 894, 895, 896, 897, 898, 899, 901, 902, 903, 905, 907, 909, 911, 912, 913, 915, 917, 918, 920, 922, 923, 924, 926, 927, 928, 930, 931, 932, 934, 935, 941, 942, 943, 944, 945, 949, 950, 951, 953, 954, 956, 958, 960, 961, 963, 965, 968, 969, 972, 974, 975, 976, 977, 981, 983, 985, 986, 991, 993, 996, 998, 1000, 1001, 1005, 1006, 1008, 1009, 1010, 1011, 1013, 1014, 1015, 1017, 1018, 1019, 1020, 1022, 1023, 1027, 1030, 1031, 1037, 1039, 1042, 1043, 1044, 1046, 1047, 1050, 1051, 1053, 1055, 1057, 1058, 1059, 1061, 1062, 1063, 1064, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1084, 1086, 1087, 1090, 1092, 1094, 1096, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1112, 1113, 1115, 1117, 1119, 1121, 1123, 1124, 1126, 1127, 1128, 1131, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
From 2003 to 2004, how many customers have paid more than three times?
paymentdate BETWEEN '2003-01-01' AND '2004-12-31'; customers who have paid more than three times refers to (COUNT(customernumber)>3);
SELECT COUNT(customernumber) FROM ( SELECT customernumber FROM payments WHERE STRFTIME('%Y', paymentDate) >= '2003' AND STRFTIME('%Y', paymentDate) <= '2004' GROUP BY customernumber HAVING COUNT(customernumber) > 3 ) T
CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,587
1,587
CREATE TABLE `payments` ( customerNumber INTEGER not null, paymentDate DATE not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "GROUP BY", "AND", "SELECT", "HAVING", "STRFTIME", "COUNT", "FROM" ]
11
medium
{ "case_1": [ 718 ], "case_2": [ 718 ], "case_3": [ 379, 718, 730, 798, 843 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 2, 4, 11, 13, 15, 20, 22, 28, 30, 32, 36, 37, 40, 47, 51, 53, 55, 62, 63, 67, 68, 69, 73, 74, 75, 78, 86, 88, 89, 93, 96, 98, 108, 109, 113, 115, 117, 118, 119, 121, 125, 126, 131, 140, 142, 143, 146, 152, 159, 160, 164, 167, 169, 170, 173, 175, 179, 182, 183, 184, 187, 188, 191, 197, 199, 202, 206, 214, 227, 229, 230, 233, 244, 247, 252, 256, 259, 267, 268, 276, 277, 286, 294, 301, 311, 314, 317, 319, 320, 325, 330, 334, 339, 341, 344, 345, 348, 349, 352, 356, 359, 364, 370, 371, 373, 374, 379, 382, 383, 391, 394, 399, 403, 406, 409, 411, 416, 417, 421, 424, 426, 436, 444, 445, 448, 454, 460, 462, 464, 466, 469, 473, 476, 477, 481, 490, 493, 500, 505, 510, 512, 515, 516, 519, 520, 526, 532, 536, 537, 538, 542, 544, 548, 551, 552, 554, 558, 559, 560, 563, 566, 581, 582, 586, 591, 594, 595, 608, 611, 613, 618, 627, 630, 632, 633, 634, 641, 645, 651, 654, 656, 659, 663, 664, 665, 667, 668, 669, 671, 680, 681, 687, 688, 690, 692, 696, 698, 703, 707, 712, 714, 718, 719, 721, 727, 730, 733, 734, 735, 739, 740, 743, 748, 749, 752, 753, 756, 760, 768, 778, 779, 790, 797, 798, 799, 800, 804, 810, 814, 817, 818, 819, 820, 824, 825, 827, 830, 831, 838, 843, 849, 851, 853, 866, 867, 869, 870, 876, 877, 886, 888, 893, 896, 901, 902, 903, 911, 917, 918, 923, 924, 927, 930, 932, 934, 935, 945, 950, 951, 954, 956, 958, 961, 963, 965, 969, 972, 975, 977, 981, 985, 986, 993, 996, 1001, 1005, 1006, 1008, 1010, 1013, 1014, 1020, 1022, 1023, 1030, 1037, 1042, 1043, 1044, 1047, 1050, 1051, 1057, 1058, 1059, 1064, 1067, 1070, 1071, 1072, 1076, 1077, 1079, 1084, 1086, 1094, 1100, 1101, 1103, 1104, 1106, 1119, 1121, 1123, 1124, 1126, 1128, 1131, 1135, 1137 ] }
car_retails
What is the average actual profit by 1937 Lincoln Berline?
average actual profit = AVG(SUBTRACT(priceEach, buyPrice)); 1937 Lincoln Berline is a product name;
SELECT SUM(T1.priceEach - T2.buyPrice) / COUNT(*) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productName = '1937 Lincoln Berline'
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,588
1,588
CREATE TABLE `products` ( productCode TEXT not null primary key, productName TEXT not null, buyPrice REAL not null ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, priceEach REAL not null, productCode )
[ "AS", "SELECT", "SUM", "INNER JOIN", "ON", "COUNT", "FROM" ]
8
simple
{ "case_1": [ -1 ], "case_2": [ 1038 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 35, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 104, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 215, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 506, 507, 509, 510, 511, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 661, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Among the motorcycles with product scale of 1:10, which of them is the most ordered by American customers?
motorcycle is a product line; American is a nationality of country = 'USA';
SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T1.productLine = 'Motorcycles' AND T1.productScale = '1:10' AND T4.country = 'USA' GROUP BY T1.productName ORDER BY SUM(T2.quantityOrdered) DESC LIMIT 1
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,589
1,589
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, country TEXT not null ) CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber ) CREATE TABLE `products` ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, foreign key productLine references productlinesproductLine ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, primary key orderNumber, productCode )
[ "GROUP BY", "AS", "AND", "SELECT", "SUM", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
19
challenging
{ "case_1": [ -1 ], "case_2": [ 470 ], "case_3": [ 8, 379, 470, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 4, 5, 6, 8, 10, 11, 12, 13, 15, 19, 20, 21, 22, 24, 26, 28, 29, 30, 33, 36, 37, 38, 39, 42, 44, 45, 47, 49, 51, 52, 53, 55, 57, 59, 62, 63, 64, 66, 68, 69, 71, 73, 74, 75, 76, 77, 78, 81, 83, 85, 86, 88, 89, 90, 93, 94, 95, 96, 98, 99, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 148, 150, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 167, 169, 170, 172, 173, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 191, 195, 197, 199, 200, 201, 202, 206, 207, 212, 213, 214, 219, 225, 226, 227, 228, 229, 233, 234, 236, 239, 240, 244, 247, 248, 252, 254, 256, 258, 261, 262, 264, 265, 266, 267, 268, 272, 275, 276, 277, 278, 279, 281, 282, 285, 286, 296, 300, 301, 304, 309, 311, 313, 314, 315, 316, 317, 319, 320, 323, 324, 325, 329, 330, 334, 335, 336, 339, 341, 342, 344, 345, 347, 348, 349, 352, 353, 356, 359, 360, 361, 363, 364, 365, 368, 370, 371, 373, 374, 376, 378, 379, 381, 382, 383, 385, 391, 393, 394, 395, 398, 402, 403, 405, 406, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 424, 425, 426, 427, 428, 429, 433, 434, 435, 436, 437, 438, 440, 444, 445, 446, 448, 450, 451, 452, 454, 455, 460, 462, 463, 464, 469, 470, 473, 475, 476, 477, 480, 482, 483, 486, 487, 488, 490, 493, 494, 495, 496, 497, 498, 500, 505, 507, 514, 515, 516, 518, 519, 520, 522, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 557, 558, 559, 560, 561, 562, 563, 564, 566, 567, 571, 575, 578, 579, 580, 581, 582, 584, 586, 588, 589, 590, 592, 595, 597, 605, 608, 609, 610, 611, 612, 613, 615, 621, 623, 624, 625, 626, 627, 628, 630, 632, 633, 634, 637, 638, 640, 641, 643, 645, 648, 650, 651, 654, 657, 658, 659, 662, 663, 664, 665, 666, 668, 669, 671, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 695, 696, 697, 698, 699, 701, 702, 703, 710, 712, 714, 715, 717, 719, 720, 721, 723, 726, 727, 733, 734, 735, 739, 740, 741, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 756, 758, 759, 760, 762, 763, 765, 767, 768, 773, 775, 776, 777, 778, 779, 780, 783, 787, 788, 790, 793, 796, 797, 799, 800, 802, 803, 804, 806, 807, 808, 810, 813, 814, 818, 819, 823, 824, 825, 827, 829, 830, 832, 835, 838, 841, 844, 848, 849, 850, 851, 853, 858, 859, 860, 861, 866, 867, 868, 869, 870, 871, 873, 874, 876, 877, 878, 879, 882, 886, 888, 889, 891, 892, 893, 895, 896, 901, 902, 905, 907, 909, 911, 912, 917, 918, 922, 923, 924, 927, 928, 929, 930, 931, 932, 934, 935, 943, 944, 949, 950, 951, 953, 954, 956, 958, 959, 961, 962, 963, 966, 967, 969, 970, 972, 973, 974, 975, 977, 981, 985, 986, 987, 991, 993, 994, 996, 1000, 1001, 1004, 1005, 1006, 1010, 1012, 1013, 1017, 1019, 1022, 1023, 1025, 1027, 1030, 1031, 1034, 1037, 1038, 1039, 1042, 1043, 1044, 1046, 1047, 1049, 1050, 1051, 1056, 1057, 1058, 1061, 1063, 1064, 1065, 1067, 1068, 1071, 1072, 1076, 1077, 1078, 1080, 1082, 1084, 1086, 1087, 1091, 1092, 1094, 1098, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1115, 1119, 1123, 1124, 1128, 1131, 1135, 1136, 1137 ] }
car_retails
Between 8/1/2003 and 8/30/2004, how many checks were issued by Mini Gifts Distributors Ltd.? Please list their check numbers.
paymentDate BETWEEN '2003-08-01' AND '2004-08-30'; Mini Gifts Distributors Ltd. Is a customer name;
SELECT T1.checkNumber FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.paymentDate >= '2003-08-01' AND T1.paymentDate <= '2004-08-30' AND T2.customerName = 'Mini Gifts Distributors Ltd.'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,590
1,590
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, customerName TEXT not null ) CREATE TABLE `payments` ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, primary key customerNumber, checkNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "AND", "SELECT", "-", "INNER JOIN", "ON", "FROM" ]
12
medium
{ "case_1": [ -1 ], "case_2": [ 523, 609 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 864, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 362, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 447, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 679, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 785, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 864, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1070, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
For the planes which has the hightest total price, how much it exceeds the average?
plane is a product line; total price = MULTIPLY(quantityOrdered, priceEach); how much the total price exceeds the average = SUBTRACT(MAX(MULTIPLY(quantityOrdered, priceEach))), AVG(priceEach));
SELECT MAX(quantityOrdered * priceEach) - AVG(priceEach) FROM orderdetails WHERE productCode IN ( SELECT productCode FROM products WHERE productLine = 'Planes' )
CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,591
1,591
CREATE TABLE `products` ( productCode TEXT not null primary key, productLine TEXT not null, foreign key productLine references productlinesproductLine ) CREATE TABLE `orderdetails` ( productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, productCode )
[ "SELECT", "IN", "AVG", "FROM", "MAX" ]
7
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 864 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 7, 22, 31, 35, 72, 76, 79, 80, 106, 109, 119, 123, 137, 140, 144, 166, 178, 200, 207, 211, 219, 220, 232, 235, 241, 246, 270, 295, 306, 315, 322, 333, 341, 366, 386, 393, 399, 407, 410, 461, 466, 498, 514, 529, 555, 557, 565, 586, 630, 633, 635, 642, 663, 696, 704, 736, 781, 784, 789, 817, 820, 833, 842, 845, 851, 856, 862, 863, 864, 872, 874, 903, 932, 948, 957, 984, 1001, 1019, 1025, 1026, 1028, 1060, 1073, 1081, 1108, 1111, 1118, 1138 ] }
car_retails
What is the total value of shipped vintage car orders from 2003-2004?
total value = SUM(MULTIPLY(quantityOrdered, priceEach)); shipped orders refers to status = 'Shipped'; vintage car is a product line; year(orderDate) between 2003 and 2004;
SELECT SUM(T2.priceEach * T2.quantityOrdered) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber WHERE T3.status = 'Shipped' AND T3.orderDate BETWEEN '2003-01-01' AND '2004-12-31'
CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,592
1,592
CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, orderDate DATE not null, status TEXT not null ) CREATE TABLE `products` ( productCode TEXT not null primary key ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, primary key orderNumber, productCode )
[ "AS", "AND", "SELECT", "SUM", "-", "INNER JOIN", "ON", "BETWEEN", "FROM" ]
17
challenging
{ "case_1": [ 379 ], "case_2": [ 379 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 864, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 350, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 864, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
Who is the sales agent of the customer who has made the highest payment? Include the full names of employee and his/her supervisor.
payment refers to amount; full name = firstName+lastName; supervisor refers to reportsTO; 'reportsTO' is the leader of the 'employeeNumber';
SELECT T1.firstName, T1.lastName, T1.reportsTo FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber ORDER BY T3.amount DESC LIMIT 1
CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,593
1,593
CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, reportsTo INTEGER, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, salesRepEmployeeNumber INTEGER, foreign key salesRepEmployeeNumber references employeesemployeeNumber ) CREATE TABLE `payments` ( customerNumber INTEGER not null, amount REAL not null, primary key customerNumber, foreign key customerNumber references customerscustomerNumber )
[ "AS", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "FROM" ]
12
medium
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 33, 34, 36, 37, 38, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 108, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 173, 174, 175, 176, 177, 179, 180, 181, 183, 184, 185, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 208, 211, 212, 213, 214, 217, 218, 219, 220, 221, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 252, 254, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 285, 286, 287, 289, 290, 291, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 352, 353, 354, 356, 357, 358, 359, 360, 361, 363, 364, 365, 368, 369, 370, 371, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 619, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 664, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 708, 710, 711, 712, 714, 715, 717, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 732, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 796, 797, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 815, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 836, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 869, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 946, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 972, 973, 974, 975, 977, 980, 981, 983, 985, 986, 987, 988, 991, 993, 994, 996, 997, 999, 1000, 1001, 1003, 1004, 1005, 1006, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1030, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1057, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1076, 1077, 1078, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1139, 1141 ] }
car_retails
What is the highest amount of order made by the sales representative in Boston? Please give the name of the product and amount.
Boston is a city; amount of order = MULTIPLY(quantityOrdered, priceEach);
SELECT T2.productName, T1.quantityOrdered * T1.priceEach FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T1.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T4.city = 'Boston' AND T4.salesRepEmployeeNumber IN ( SELECT employeeNumber FROM employees WHERE jobTitle = 'Sales Rep' ) ORDER BY T1.quantityOrdered DESC LIMIT 1
CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,594
1,594
CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, jobTitle TEXT not null, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, city TEXT not null, salesRepEmployeeNumber INTEGER, foreign key salesRepEmployeeNumber references employeesemployeeNumber ) CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber ) CREATE TABLE `products` ( productCode TEXT not null primary key, productName TEXT not null ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, primary key orderNumber, productCode )
[ "AS", "AND", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "IN", "ON", "DESC", "FROM" ]
19
challenging
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 379, 470, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 4, 5, 7, 8, 10, 11, 12, 19, 20, 21, 22, 24, 26, 29, 30, 33, 36, 37, 38, 39, 44, 45, 47, 49, 51, 52, 53, 55, 57, 59, 62, 63, 66, 68, 69, 71, 73, 74, 75, 76, 85, 86, 88, 89, 90, 93, 95, 96, 98, 99, 106, 111, 112, 113, 115, 116, 117, 118, 119, 121, 125, 127, 128, 129, 131, 138, 140, 141, 142, 143, 144, 146, 150, 152, 154, 158, 159, 160, 162, 163, 164, 166, 167, 169, 170, 172, 175, 176, 177, 179, 180, 183, 184, 187, 188, 197, 199, 200, 202, 206, 207, 213, 214, 219, 227, 229, 233, 239, 240, 244, 247, 256, 258, 262, 265, 266, 267, 268, 272, 275, 276, 277, 278, 281, 282, 286, 296, 301, 309, 311, 313, 314, 315, 317, 319, 320, 324, 325, 329, 330, 334, 336, 339, 341, 342, 345, 349, 353, 356, 361, 364, 365, 368, 370, 373, 374, 376, 378, 379, 381, 382, 383, 385, 391, 393, 394, 395, 398, 402, 403, 405, 406, 408, 409, 411, 413, 414, 416, 417, 419, 424, 425, 426, 427, 428, 429, 433, 434, 435, 436, 437, 438, 440, 444, 445, 446, 448, 451, 452, 454, 455, 460, 462, 463, 464, 469, 470, 475, 476, 477, 480, 482, 490, 493, 494, 495, 496, 497, 498, 500, 505, 507, 514, 515, 516, 519, 520, 522, 524, 526, 528, 529, 530, 532, 533, 536, 537, 538, 539, 541, 542, 544, 548, 552, 555, 557, 558, 559, 560, 561, 562, 563, 566, 567, 578, 579, 581, 582, 584, 586, 588, 589, 590, 592, 595, 605, 608, 610, 611, 612, 613, 615, 621, 624, 625, 626, 627, 630, 632, 633, 634, 637, 638, 641, 643, 645, 648, 651, 654, 657, 659, 663, 665, 666, 668, 669, 671, 675, 677, 678, 681, 683, 684, 685, 686, 687, 688, 690, 691, 693, 697, 699, 701, 702, 712, 714, 715, 719, 726, 727, 733, 734, 735, 739, 740, 741, 743, 746, 747, 749, 752, 753, 754, 756, 758, 759, 760, 763, 765, 767, 768, 773, 775, 776, 777, 778, 780, 783, 788, 790, 793, 797, 799, 800, 803, 804, 806, 807, 808, 810, 814, 818, 819, 823, 824, 825, 827, 829, 830, 832, 835, 838, 844, 848, 849, 850, 851, 853, 858, 859, 860, 861, 866, 867, 870, 873, 874, 876, 877, 878, 879, 886, 888, 889, 891, 892, 893, 895, 896, 901, 902, 905, 907, 911, 917, 918, 923, 924, 927, 928, 929, 930, 931, 932, 934, 935, 944, 949, 950, 951, 953, 954, 956, 958, 961, 962, 963, 966, 967, 969, 970, 973, 974, 975, 977, 981, 985, 986, 991, 994, 996, 1000, 1001, 1004, 1005, 1006, 1010, 1013, 1017, 1019, 1022, 1023, 1025, 1027, 1031, 1034, 1037, 1038, 1039, 1042, 1044, 1046, 1047, 1049, 1050, 1051, 1056, 1058, 1061, 1063, 1064, 1065, 1067, 1068, 1071, 1072, 1080, 1084, 1086, 1092, 1094, 1100, 1101, 1103, 1104, 1105, 1109, 1115, 1119, 1123, 1124, 1128, 1131, 1136, 1137 ] }
car_retails
What is the total actual profit gained from orders made by American customers from 2003-01-06 to 2005-05-09?
total actual profit = SUM(SUBTRACT(priceEach, buyPrice)); American is a nationality of country = 'USA'; orderDate BETWEEN '2003-01-06' AND '2005-05-09';
SELECT SUM(T2.priceEach - T1.buyPrice) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T3.orderDate > '2003-01-05' AND T3.orderDate < '2005-05-10'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,595
1,595
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key ) CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, orderDate DATE not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber ) CREATE TABLE `products` ( productCode TEXT not null primary key, buyPrice REAL not null ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, productCode TEXT not null references products, priceEach REAL not null, primary key orderNumber, productCode )
[ "AS", "AND", "SELECT", "SUM", "-", "INNER JOIN", "ON", "FROM" ]
18
challenging
{ "case_1": [ -1 ], "case_2": [ 470 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 798, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 33, 34, 36, 37, 39, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 88, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 260, 261, 262, 264, 265, 266, 267, 268, 269, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 287, 289, 290, 292, 295, 296, 297, 298, 299, 300, 301, 302, 304, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 368, 369, 370, 373, 374, 375, 376, 378, 379, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 422, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 444, 445, 446, 448, 449, 450, 451, 452, 454, 455, 456, 457, 459, 460, 462, 463, 464, 465, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 505, 507, 509, 510, 511, 514, 515, 516, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 544, 547, 548, 550, 552, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 592, 593, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 657, 658, 659, 660, 662, 663, 665, 666, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 710, 711, 712, 714, 715, 717, 720, 721, 722, 723, 724, 725, 726, 727, 728, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 818, 819, 822, 823, 824, 825, 827, 828, 829, 830, 832, 833, 834, 835, 837, 838, 839, 841, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 904, 905, 907, 908, 909, 910, 911, 912, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 943, 944, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1071, 1072, 1074, 1078, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }
car_retails
From which branch does the sales representative employee who made the most sales in 2005? Please indicates its full address and phone number.
orderDate between '2005-01-01' and '2005-12-31'; full address = addressLine1+addressLine2;
SELECT T3.addressLine1, T3.addressLine2, T3.phone FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber INNER JOIN customers AS T3 ON T2.customerNumber = T3.customerNumber INNER JOIN employees AS T4 ON T3.salesRepEmployeeNumber = T4.employeeNumber INNER JOIN offices AS T5 ON T4.officeCode = T5.officeCode WHERE STRFTIME('%Y', T2.orderDate) = '2005' AND T4.jobTitle = 'Sales Rep' ORDER BY T1.quantityOrdered DESC LIMIT 1
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,596
1,596
CREATE TABLE `offices` ( officeCode TEXT not null primary key, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT ) CREATE TABLE `employees` ( employeeNumber INTEGER not null primary key, officeCode TEXT not null, jobTitle TEXT not null, foreign key officeCode references officesofficeCode, foreign key reportsTo references employeesemployeeNumber ) CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, salesRepEmployeeNumber INTEGER, foreign key salesRepEmployeeNumber references employeesemployeeNumber ) CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, orderDate DATE not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber ) CREATE TABLE `orderdetails` ( CREATE TABLE "orderdetails" orderNumber INTEGER not null references orders, quantityOrdered INTEGER not null, primary key orderNumber )
[ "AS", "AND", "SELECT", "ORDER BY", "LIMIT", "INNER JOIN", "ON", "DESC", "STRFTIME", "FROM" ]
20
challenging
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 379, 470, 648, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 1, 4, 5, 8, 10, 11, 12, 19, 20, 21, 22, 24, 26, 29, 30, 33, 36, 37, 38, 39, 44, 45, 47, 49, 51, 52, 53, 55, 57, 59, 62, 63, 66, 68, 69, 71, 73, 74, 75, 76, 85, 86, 88, 89, 90, 93, 95, 96, 98, 99, 111, 112, 113, 115, 116, 117, 118, 119, 121, 125, 127, 128, 129, 131, 138, 141, 142, 143, 144, 146, 150, 152, 154, 158, 159, 160, 162, 163, 164, 167, 169, 170, 172, 175, 176, 177, 179, 180, 183, 184, 187, 188, 197, 199, 200, 202, 206, 213, 214, 219, 227, 229, 233, 239, 240, 244, 247, 256, 258, 262, 265, 266, 267, 268, 272, 275, 276, 277, 278, 281, 282, 286, 296, 301, 309, 311, 313, 314, 315, 317, 319, 320, 322, 324, 325, 329, 330, 334, 336, 339, 341, 342, 345, 349, 353, 356, 359, 361, 364, 365, 368, 370, 373, 374, 376, 378, 379, 381, 382, 383, 385, 391, 393, 394, 395, 398, 402, 403, 405, 406, 408, 409, 411, 413, 414, 416, 417, 419, 424, 425, 426, 427, 428, 429, 433, 434, 435, 436, 437, 438, 440, 444, 445, 446, 448, 451, 452, 454, 455, 460, 462, 463, 464, 469, 470, 475, 476, 477, 480, 482, 490, 493, 494, 495, 496, 497, 498, 500, 505, 507, 514, 515, 516, 519, 520, 522, 524, 526, 528, 529, 530, 532, 533, 536, 537, 538, 539, 541, 542, 544, 548, 552, 557, 558, 559, 560, 561, 562, 563, 566, 567, 578, 579, 581, 582, 584, 586, 588, 589, 590, 592, 595, 605, 608, 610, 611, 612, 613, 615, 621, 624, 625, 626, 627, 632, 633, 634, 637, 638, 641, 643, 645, 648, 651, 654, 657, 659, 663, 665, 666, 668, 669, 671, 675, 677, 678, 681, 683, 684, 685, 686, 687, 688, 690, 691, 693, 697, 699, 701, 702, 712, 714, 715, 719, 726, 727, 733, 734, 735, 739, 740, 741, 743, 746, 747, 749, 752, 753, 754, 756, 758, 759, 760, 763, 765, 767, 768, 773, 775, 776, 777, 778, 780, 783, 788, 790, 793, 797, 799, 800, 803, 804, 806, 807, 808, 810, 814, 818, 819, 823, 824, 825, 827, 829, 830, 832, 835, 838, 844, 848, 849, 850, 851, 853, 858, 859, 860, 861, 866, 867, 870, 873, 876, 877, 878, 879, 886, 888, 889, 891, 892, 893, 895, 896, 901, 902, 905, 907, 911, 917, 918, 923, 924, 927, 928, 929, 930, 931, 932, 934, 935, 944, 949, 950, 951, 953, 954, 956, 958, 961, 962, 963, 966, 967, 969, 970, 973, 974, 975, 977, 981, 985, 986, 991, 994, 996, 1000, 1001, 1004, 1005, 1006, 1010, 1013, 1017, 1019, 1022, 1023, 1025, 1027, 1031, 1034, 1037, 1038, 1039, 1042, 1044, 1046, 1047, 1049, 1050, 1051, 1056, 1058, 1061, 1063, 1064, 1065, 1067, 1068, 1071, 1072, 1080, 1084, 1086, 1092, 1094, 1100, 1101, 1103, 1104, 1105, 1109, 1115, 1119, 1123, 1124, 1128, 1131, 1136, 1137 ] }
car_retails
What is the phone number of all companies where the last name of the contact person starts with the letter M and are not from Germany?
last name of contact person starts with M refers to lastName LIKE 'M%'; Germany is a country; not from Germany refers to country<>'Germany';
SELECT phone FROM customers WHERE contactLastName LIKE 'M%' AND country != 'Germany'
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,597
1,597
CREATE TABLE `customers` ( contactLastName TEXT not null, phone TEXT not null, country TEXT not null )
[ "LIKE", "AND", "SELECT", "FROM" ]
4
simple
{ "case_1": [ 168, 730 ], "case_2": [ 168, 730 ], "case_3": [ 8, 168, 470, 648, 718, 730, 798, 843, 864 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 2, 3, 4, 5, 8, 10, 12, 19, 20, 21, 22, 24, 26, 30, 32, 33, 37, 38, 39, 40, 43, 44, 45, 47, 50, 51, 52, 53, 56, 57, 59, 63, 66, 67, 68, 69, 71, 73, 74, 75, 76, 79, 81, 82, 85, 88, 90, 93, 95, 96, 98, 99, 100, 109, 111, 112, 113, 114, 115, 116, 117, 118, 119, 125, 126, 127, 128, 129, 131, 136, 138, 141, 142, 143, 144, 146, 152, 154, 158, 160, 163, 164, 168, 169, 170, 172, 175, 176, 177, 179, 180, 183, 184, 187, 197, 200, 202, 204, 212, 214, 219, 223, 227, 230, 239, 240, 244, 247, 255, 256, 258, 259, 262, 263, 264, 265, 266, 267, 268, 270, 272, 275, 276, 277, 278, 282, 294, 296, 301, 305, 314, 315, 317, 319, 325, 330, 339, 341, 348, 350, 356, 361, 362, 367, 368, 370, 373, 374, 376, 377, 382, 383, 385, 391, 393, 395, 397, 398, 399, 402, 403, 405, 406, 407, 408, 413, 414, 415, 416, 417, 418, 419, 421, 424, 425, 426, 427, 428, 430, 433, 436, 437, 438, 439, 440, 444, 446, 448, 451, 452, 455, 463, 464, 469, 470, 475, 476, 477, 480, 482, 490, 492, 493, 494, 496, 497, 498, 500, 507, 510, 512, 514, 515, 516, 519, 520, 522, 524, 525, 526, 528, 529, 530, 532, 533, 537, 539, 541, 544, 546, 551, 554, 557, 558, 559, 561, 562, 563, 581, 582, 584, 586, 588, 589, 591, 594, 595, 598, 599, 601, 605, 608, 610, 612, 613, 615, 618, 622, 624, 625, 626, 627, 629, 632, 633, 637, 641, 643, 648, 651, 656, 663, 666, 667, 668, 671, 675, 677, 678, 679, 680, 683, 684, 685, 686, 687, 690, 692, 693, 697, 699, 702, 707, 712, 714, 715, 716, 718, 719, 726, 727, 730, 734, 735, 738, 739, 740, 741, 743, 746, 747, 749, 753, 754, 756, 758, 760, 763, 765, 767, 768, 773, 774, 775, 776, 777, 780, 783, 785, 787, 788, 793, 794, 796, 797, 798, 799, 800, 804, 806, 807, 808, 810, 814, 817, 819, 820, 824, 825, 828, 829, 830, 831, 832, 835, 838, 840, 841, 843, 844, 848, 849, 850, 851, 853, 855, 858, 859, 860, 861, 864, 865, 867, 870, 873, 875, 877, 878, 879, 886, 888, 892, 895, 896, 902, 903, 905, 907, 909, 917, 918, 920, 922, 923, 924, 928, 930, 931, 932, 935, 944, 945, 948, 949, 953, 954, 956, 958, 961, 965, 969, 974, 979, 980, 985, 986, 991, 996, 998, 1000, 1001, 1008, 1009, 1014, 1017, 1018, 1019, 1020, 1022, 1023, 1027, 1031, 1039, 1042, 1044, 1046, 1054, 1057, 1058, 1059, 1061, 1063, 1064, 1067, 1068, 1070, 1071, 1072, 1073, 1079, 1080, 1081, 1084, 1086, 1092, 1096, 1098, 1100, 1101, 1103, 1104, 1105, 1109, 1111, 1115, 1117, 1119, 1121, 1123, 1126, 1128, 1131, 1136 ] }
car_retails
Calculate the average amount of payments made by customers during the first half of 2004.
average amount of payments = DIVIDE(SUM(amount), COUNT(customerNumber); first half of 2014 refers to paymentDate > = '2004-01-01' AND paymentDate < '2004-07-01;
SELECT AVG(amount) FROM payments WHERE paymentDate BETWEEN '2004-01-01' AND '2004-06-30'
CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,598
1,598
CREATE TABLE `payments` ( paymentDate DATE not null, amount REAL not null )
[ "AND", "SELECT", "-", "AVG", "BETWEEN", "FROM" ]
9
simple
{ "case_1": [ 864 ], "case_2": [ 864 ], "case_3": [ 798, 864 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 2, 10, 21, 32, 39, 43, 45, 74, 76, 79, 85, 93, 98, 112, 115, 128, 141, 144, 154, 158, 172, 173, 180, 183, 184, 187, 197, 223, 240, 244, 256, 259, 272, 296, 305, 315, 319, 325, 339, 350, 356, 362, 368, 382, 383, 391, 393, 399, 403, 416, 421, 425, 436, 444, 446, 448, 451, 463, 482, 493, 496, 498, 507, 510, 514, 520, 522, 529, 530, 544, 559, 562, 586, 601, 624, 643, 656, 667, 675, 677, 679, 684, 686, 693, 740, 746, 754, 756, 758, 777, 785, 788, 798, 800, 810, 817, 829, 835, 838, 849, 858, 864, 870, 878, 905, 917, 924, 930, 954, 974, 985, 1001, 1019, 1031, 1067, 1068, 1081, 1092, 1101, 1111, 1123 ] }
car_retails
Of all the orders placed and shipped throughout the year 2005, what percentage of those orders corresponds to customer number 186?
shipped orders refers to status = 'shipped'; year(shippedDate) = 2005; percentage = DIVIDE(SUM(customerNumber = 186)), COUNT(orderNumber)) as percentage;
SELECT CAST(SUM(CASE WHEN customerNumber = 186 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(orderNumber) FROM orders WHERE status = 'Shipped' AND shippedDate BETWEEN '2005-01-01' AND '2005-12-31'
CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,599
1,599
CREATE TABLE `orders` ( orderNumber INTEGER not null primary key, shippedDate DATE, status TEXT not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber )
[ "CASE WHEN", "AS", "AND", "SELECT", "SUM", "CASE", "-", "CAST", "COUNT", "BETWEEN", "FROM" ]
15
medium
{ "case_1": [ 798 ], "case_2": [ 798 ], "case_3": [ 16, 798 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 2, 6, 10, 16, 24, 32, 35, 39, 42, 61, 64, 71, 74, 77, 81, 87, 93, 98, 104, 106, 112, 113, 115, 119, 120, 127, 129, 141, 148, 152, 153, 155, 158, 169, 173, 183, 184, 187, 189, 191, 192, 195, 197, 201, 207, 212, 215, 219, 223, 225, 226, 234, 236, 244, 248, 254, 256, 261, 264, 267, 271, 279, 299, 300, 304, 305, 316, 317, 319, 322, 323, 325, 335, 339, 347, 356, 360, 362, 375, 382, 383, 391, 393, 402, 403, 406, 409, 412, 415, 416, 423, 427, 436, 438, 444, 448, 451, 452, 453, 458, 476, 478, 485, 486, 487, 493, 500, 504, 510, 514, 517, 518, 520, 535, 537, 540, 544, 547, 550, 559, 562, 563, 564, 571, 573, 575, 580, 581, 597, 601, 620, 623, 628, 640, 646, 658, 662, 666, 667, 676, 677, 682, 686, 690, 709, 710, 723, 740, 744, 747, 750, 753, 756, 762, 772, 776, 777, 787, 788, 795, 796, 798, 800, 802, 808, 810, 813, 827, 832, 838, 841, 848, 849, 868, 870, 871, 874, 894, 896, 909, 912, 913, 917, 922, 924, 926, 930, 943, 944, 954, 958, 959, 979, 985, 998, 1008, 1012, 1023, 1031, 1062, 1064, 1067, 1068, 1069, 1070, 1072, 1078, 1082, 1087, 1092, 1093, 1098, 1100, 1101, 1121, 1123, 1128, 1131, 1133, 1134, 1135 ] }
car_retails
How many customers with a canceled shipment have a credit limit greater than 115,000?
cancelled shipment refers to status = 'cancelled'; creditLimit > 115000;
SELECT COUNT(T1.customerNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.status = 'Cancelled' AND T1.creditLimit > 115000
CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) )
CREATE TABLE offices ( officeCode TEXT not null primary key, city TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, state TEXT, country TEXT not null, postalCode TEXT not null, territory TEXT not null ) CREATE TABLE employees ( employeeNumber INTEGER not null primary key, lastName TEXT not null, firstName TEXT not null, extension TEXT not null, email TEXT not null, officeCode TEXT not null, reportsTo INTEGER, jobTitle TEXT not null, foreign key (officeCode) references offices(officeCode), foreign key (reportsTo) references employees(employeeNumber) ) CREATE TABLE customers ( customerNumber INTEGER not null primary key, customerName TEXT not null, contactLastName TEXT not null, contactFirstName TEXT not null, phone TEXT not null, addressLine1 TEXT not null, addressLine2 TEXT, city TEXT not null, state TEXT, postalCode TEXT, country TEXT not null, salesRepEmployeeNumber INTEGER, creditLimit REAL, foreign key (salesRepEmployeeNumber) references employees(employeeNumber) ) CREATE TABLE orders ( orderNumber INTEGER not null primary key, orderDate DATE not null, requiredDate DATE not null, shippedDate DATE, status TEXT not null, comments TEXT, customerNumber INTEGER not null, foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE payments ( customerNumber INTEGER not null, checkNumber TEXT not null, paymentDate DATE not null, amount REAL not null, primary key (customerNumber, checkNumber), foreign key (customerNumber) references customers(customerNumber) ) CREATE TABLE productlines ( productLine TEXT not null primary key, textDescription TEXT, htmlDescription TEXT, image BLOB ) CREATE TABLE products ( productCode TEXT not null primary key, productName TEXT not null, productLine TEXT not null, productScale TEXT not null, productVendor TEXT not null, productDescription TEXT not null, quantityInStock INTEGER not null, buyPrice REAL not null, MSRP REAL not null, foreign key (productLine) references productlines(productLine) ) CREATE TABLE "orderdetails" ( orderNumber INTEGER not null references orders, productCode TEXT not null references products, quantityOrdered INTEGER not null, priceEach REAL not null, orderLineNumber INTEGER not null, primary key (orderNumber, productCode) )
na
1,600
1,600
CREATE TABLE `customers` ( customerNumber INTEGER not null primary key, creditLimit REAL ) CREATE TABLE `orders` ( status TEXT not null, customerNumber INTEGER not null, foreign key customerNumber references customerscustomerNumber )
[ "AS", "AND", "SELECT", "INNER JOIN", "ON", "COUNT", "FROM" ]
8
simple
{ "case_1": [ -1 ], "case_2": [ -1 ], "case_3": [ 8, 16, 379, 470, 523, 609, 648, 718, 730, 798, 843, 1038 ], "case_4": [ 8, 16, 168, 379, 470, 523, 609, 648, 718, 730, 798, 843, 864, 1038 ], "case_5": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 18, 19, 20, 21, 22, 23, 24, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 51, 52, 53, 55, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 95, 96, 97, 98, 99, 101, 102, 105, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 119, 120, 121, 125, 126, 127, 128, 129, 130, 131, 132, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 150, 151, 152, 153, 154, 155, 158, 159, 160, 162, 163, 164, 165, 166, 167, 169, 170, 171, 172, 175, 176, 177, 178, 179, 180, 183, 184, 186, 187, 188, 189, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 206, 207, 211, 212, 213, 214, 217, 218, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230, 232, 233, 234, 235, 236, 239, 240, 241, 242, 243, 244, 246, 247, 248, 250, 254, 256, 257, 258, 259, 260, 261, 262, 264, 265, 266, 267, 268, 269, 271, 272, 275, 276, 277, 278, 279, 280, 281, 282, 284, 286, 287, 289, 290, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 329, 330, 333, 334, 335, 336, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 349, 353, 354, 356, 357, 358, 360, 361, 363, 364, 365, 367, 368, 369, 370, 373, 374, 375, 376, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 398, 399, 401, 402, 403, 405, 406, 407, 408, 409, 411, 412, 413, 414, 415, 416, 417, 419, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 440, 441, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 498, 499, 500, 501, 503, 504, 505, 507, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 528, 529, 530, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 547, 548, 550, 552, 554, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 569, 570, 571, 572, 573, 574, 575, 577, 578, 579, 580, 581, 582, 584, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 600, 601, 602, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 618, 620, 621, 623, 624, 625, 626, 627, 628, 630, 631, 632, 633, 634, 636, 637, 638, 639, 640, 641, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 665, 666, 667, 668, 669, 670, 671, 672, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 685, 686, 687, 688, 690, 691, 692, 693, 694, 695, 696, 697, 699, 700, 701, 702, 704, 705, 706, 707, 710, 711, 712, 714, 715, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 730, 733, 734, 735, 736, 739, 740, 741, 742, 743, 744, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 786, 787, 788, 790, 792, 793, 795, 796, 797, 798, 799, 800, 802, 803, 804, 805, 806, 807, 808, 809, 810, 812, 813, 814, 817, 818, 819, 820, 822, 823, 824, 825, 827, 828, 829, 830, 831, 832, 833, 834, 835, 837, 838, 839, 841, 843, 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 866, 867, 868, 870, 871, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 885, 886, 887, 888, 889, 891, 892, 893, 894, 895, 896, 897, 898, 900, 901, 902, 903, 904, 905, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 922, 923, 924, 925, 926, 927, 928, 930, 931, 932, 934, 935, 936, 937, 938, 940, 941, 943, 944, 945, 949, 950, 951, 952, 953, 954, 956, 958, 959, 961, 962, 963, 964, 965, 966, 967, 969, 970, 971, 973, 974, 975, 977, 980, 981, 985, 986, 988, 991, 993, 994, 996, 997, 998, 999, 1000, 1001, 1003, 1005, 1006, 1008, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1020, 1022, 1023, 1025, 1027, 1029, 1031, 1033, 1034, 1035, 1037, 1038, 1039, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1049, 1050, 1051, 1052, 1056, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1078, 1079, 1080, 1082, 1084, 1085, 1086, 1087, 1089, 1091, 1092, 1094, 1095, 1098, 1099, 1100, 1101, 1103, 1104, 1105, 1106, 1109, 1111, 1112, 1113, 1114, 1115, 1116, 1118, 1119, 1121, 1122, 1123, 1124, 1126, 1128, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137 ] }