Update README.md
Browse files
README.md
CHANGED
|
@@ -109,4 +109,81 @@ tokenizer = AutoTokenizer.from_pretrained("PipableAI/pipSQL-1.3b")
|
|
| 109 |
inputs = tokenizer(text, return_tensors="pt")
|
| 110 |
outputs = model.generate(**inputs, max_new_tokens=200)
|
| 111 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split('<sql>')[1].split('</sql>')[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
```
|
|
|
|
| 109 |
inputs = tokenizer(text, return_tensors="pt")
|
| 110 |
outputs = model.generate(**inputs, max_new_tokens=200)
|
| 111 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True).split('<sql>')[1].split('</sql>')[0])
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
## Examples
|
| 115 |
+
|
| 116 |
+
### Schema
|
| 117 |
+
```sql
|
| 118 |
+
CREATE TABLE Products (
|
| 119 |
+
product_id number,
|
| 120 |
+
parent_product_id number,
|
| 121 |
+
product_name text,
|
| 122 |
+
product_price number,
|
| 123 |
+
product_color text,
|
| 124 |
+
product_size text,
|
| 125 |
+
product_description text);
|
| 126 |
+
|
| 127 |
+
CREATE TABLE Customers (
|
| 128 |
+
customer_id number,
|
| 129 |
+
gender_code text,
|
| 130 |
+
customer_first_name text,
|
| 131 |
+
customer_middle_initial text,
|
| 132 |
+
customer_last_name text,
|
| 133 |
+
email_address text,
|
| 134 |
+
login_name text,
|
| 135 |
+
login_password text,
|
| 136 |
+
phone_number text,
|
| 137 |
+
address_line_1 text,
|
| 138 |
+
town_city text,
|
| 139 |
+
county text,
|
| 140 |
+
country text);
|
| 141 |
+
|
| 142 |
+
CREATE TABLE Customer_Payment_Methods (
|
| 143 |
+
customer_id number,
|
| 144 |
+
payment_method_code text);
|
| 145 |
+
|
| 146 |
+
CREATE TABLE Invoices (
|
| 147 |
+
invoice_number number,
|
| 148 |
+
invoice_status_code text,
|
| 149 |
+
invoice_date time);
|
| 150 |
+
|
| 151 |
+
CREATE TABLE Orders (
|
| 152 |
+
order_id number,
|
| 153 |
+
customer_id number,
|
| 154 |
+
order_status_code text,
|
| 155 |
+
date_order_placed time);
|
| 156 |
+
|
| 157 |
+
CREATE TABLE Order_Items (
|
| 158 |
+
order_item_id number,
|
| 159 |
+
product_id number,
|
| 160 |
+
order_id number,
|
| 161 |
+
order_item_status_code text);
|
| 162 |
+
|
| 163 |
+
CREATE TABLE Shipments (
|
| 164 |
+
shipment_id number,
|
| 165 |
+
order_id number,
|
| 166 |
+
invoice_number number,
|
| 167 |
+
shipment_tracking_number text,
|
| 168 |
+
shipment_date time);
|
| 169 |
+
|
| 170 |
+
CREATE TABLE Shipment_Items (
|
| 171 |
+
shipment_id number,
|
| 172 |
+
order_item_id number);
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
### Questions
|
| 176 |
+
What is the most popular payment method?
|
| 177 |
+
```sql
|
| 178 |
+
SELECT payment_method_code FROM Customer_Payment_Methods GROUP BY payment_method_code ORDER BY count(*) DESC LIMIT 1;
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
What are the product price and the product size of the products whose price is above average?
|
| 182 |
+
```sql
|
| 183 |
+
SELECT product_price , product_size FROM products WHERE product_price > (SELECT avg(product_price) FROM products)
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
What is the most uncommon order status?
|
| 187 |
+
```sql
|
| 188 |
+
SELECT order_status_code FROM orders GROUP BY order_status_code ORDER BY count(*) ASC LIMIT 1;
|
| 189 |
```
|