lianghsun/bird-text2sql-bench huggingface dataset:
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
What proportion of a pair of words in the Catalan language have been repeated less than 80 times?

### Hint
Pair is a relationship of two words: w1st and w2nd, where w1st is word id of the first word and w2nd is a word id of the second word; in the Catalan language refers to lid; repeated less than 80 times refers to occurrences < 80; DIVIDE(COUNT(lid where occurrences < 80), COUNT(lid)) as percentage;

### SQL
SELECT CAST(COUNT(CASE WHEN occurrences < 80 THEN lid ELSE NULL END) AS REAL) * 100 / COUNT(lid) FROM biwords
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
How many Catalan-language Wikipedia pages are there overall?

### Hint
Catalan-language refers to lang = 'ca';

### SQL
SELECT pages FROM langs WHERE lang = 'ca'
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
Please list any three Wikipedia pages that are written in Catalan, together with their titles and revision page numbers.

### Hint
in Catalan means in Catalan-language and refers to lid = 1; revision page numbers refer to revision;

### SQL
SELECT title, revision FROM pages WHERE lid = 1 LIMIT 3
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
What is the language of the pair of words numbered 1 and 616?

### Hint
Pair is a relationship of two words: w1st and w2nd, where w1st is word id of the first word and w2nd is a word id of the second word; w1st = 1; w2nd = 616;

### SQL
SELECT T2.lang FROM biwords AS T1 INNER JOIN langs AS T2 ON T1.lid = T2.lid WHERE T1.w1st = 1 AND T1.w2nd = 616
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
How many times does the Catalan word "nombre" repeat itself?

### Hint
the Catalan means Catalan language and refers to lid = 1; How many times repeat refers to occurrences;

### SQL
SELECT T1.occurrences FROM langs_words AS T1 INNER JOIN words AS T2 ON T1.wid = T2.wid WHERE T2.word = 'nombre'
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
What is the second word in the pair of words number 1 and 8968?

### Hint
Pair is a relationship of two words: w1st and w2nd, where w1st is word id of the first word and w2nd is a word id of the second word; w1st = 1; w2nd = 8968;

### SQL
SELECT word FROM words WHERE wid = 8968
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
Which word has the most repetitions in the Catalan language?

### Hint
the most repetitions refer to MAX(occurrences); Catalan language refers to lid = 1;

### SQL
SELECT T2.word FROM langs_words AS T1 INNER JOIN words AS T2 ON T1.wid = T2.wid WHERE T1.occurrences = ( SELECT MAX(occurrences) FROM langs_words )
### Database Schema
CREATE TABLE langs(lid    INTEGER PRIMARY KEY AUTOINCREMENT,
                            lang   TEXT UNIQUE,
                            locale TEXT UNIQUE,
                            pages  INTEGER DEFAULT 0,  -- total pages in this language
                            words  INTEGER DEFAULT 0)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE pages(pid INTEGER PRIMARY KEY AUTOINCREMENT,
                            lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                            page INTEGER DEFAULT NULL, -- wikipedia page id
                            revision INTEGER DEFAULT NULL, -- wikipedia revision page id
                            title TEXT,
                            words INTEGER DEFAULT 0, -- number of different words in this page
                            UNIQUE(lid,page,title))

CREATE TABLE words(wid INTEGER PRIMARY KEY AUTOINCREMENT,
                            word        TEXT UNIQUE,
                            occurrences INTEGER DEFAULT 0)

CREATE TABLE langs_words(lid INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER, -- repetitions of this word in this language
                                        PRIMARY KEY(lid,wid))
                                        WITHOUT ROWID

CREATE TABLE pages_words(pid INTEGER REFERENCES pages(pid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        wid INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                        occurrences INTEGER DEFAULT 0, -- times this word appears into this page
                                        PRIMARY KEY(pid,wid))
                                        WITHOUT ROWID

CREATE TABLE biwords(lid    INTEGER REFERENCES langs(lid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w1st   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                w2nd   INTEGER REFERENCES words(wid) ON UPDATE CASCADE ON DELETE CASCADE,
                                occurrences INTEGER DEFAULT 0, -- times this pair appears in this language/page
                                PRIMARY KEY(lid,w1st,w2nd))
                                WITHOUT ROWID

### Question
How many times on page number 44 does the word "votives" appear?

### Hint
How many times refers to occurrences; page number 44 refers to pid = 44;

### SQL
SELECT T2.occurrences FROM words AS T1 INNER JOIN pages_words AS T2 ON T1.wid = T2.wid WHERE T1.word = 'votives' AND T2.pid = 44