mirror of
https://github.com/supleed2/cch23-8bit.git
synced 2024-12-22 14:05:48 +00:00
Tidy Day 13 SQL
This commit is contained in:
parent
e685669c32
commit
f33fcacece
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "select sum(quantity) as \"sq!\", gift_name as \"gift_name!\"\n from orders group by gift_name order by \"sq!\" desc",
|
||||
"query": "select sum(quantity) as \"sq!\", gift_name as \"gift_name!\" from orders group by gift_name order by \"sq!\" desc",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
@ -22,5 +22,5 @@
|
|||
true
|
||||
]
|
||||
},
|
||||
"hash": "481edabd076d347adade420c156f8de4837e8724a405e7f2b482efe074d97202"
|
||||
"hash": "151f4eccea644038b2c09878867168afca3e5adbbfa7848618c29646e2db8ae3"
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "create table orders ( id INT PRIMARY KEY, region_id INT, gift_name VARCHAR(50), quantity INT )",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": []
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "2b97a0afac420f8e63820a44050e0a33cfae125e7f5fe3efc2e16e9ec14f806d"
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "create table orders (\n id INT PRIMARY KEY,\n region_id INT,\n gift_name VARCHAR(50),\n quantity INT\n )",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": []
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "a85986b4dd4eb8c6e86b01ad38d0b9558d5519d218ee25a6a3bb64d0c6f49c61"
|
||||
}
|
|
@ -36,11 +36,11 @@ async fn reset(State(state): State<Day13State>) -> Result<StatusCode, StatusCode
|
|||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
sqlx::query!(
|
||||
"create table orders (
|
||||
id INT PRIMARY KEY,
|
||||
region_id INT,
|
||||
gift_name VARCHAR(50),
|
||||
quantity INT
|
||||
"create table orders ( \
|
||||
id INT PRIMARY KEY, \
|
||||
region_id INT, \
|
||||
gift_name VARCHAR(50), \
|
||||
quantity INT \
|
||||
)"
|
||||
)
|
||||
.execute(&state.pool)
|
||||
|
@ -95,7 +95,7 @@ async fn popular(
|
|||
State(state): State<Day13State>,
|
||||
) -> Result<impl IntoResponse, (StatusCode, String)> {
|
||||
let gifts = sqlx::query!(
|
||||
"select sum(quantity) as \"sq!\", gift_name as \"gift_name!\"
|
||||
"select sum(quantity) as \"sq!\", gift_name as \"gift_name!\" \
|
||||
from orders group by gift_name order by \"sq!\" desc"
|
||||
)
|
||||
.fetch_all(&state.pool)
|
||||
|
|
Loading…
Reference in a new issue