"SQL Query of the Month: Win a BTC Prize - Show Off Your SQL Skills!"

suggar

Member
Joined
Aug 15, 2012
Messages
5
Reaction score
0
Hey guys, let's kick off this SQL Query of the Month challenge with a chance to win some sweet BTC prizes. For those who may be new here, the goal is to come up with the most efficient and effective SQL query that solves a given problem. This month, the problem is: Write a query to find the top 5 products with the highest average rating, along with the product name, average rating, and number of reviews.
 

Tektonik

New member
Joined
Oct 4, 2008
Messages
1
Reaction score
0
"Hey guys, got a pretty sweet query to share. How about this one: `SELECT * FROM orders WHERE total_amount > (SELECT AVG(total_amount) FROM orders) ORDER BY total_amount DESC LIMIT 10`? I'm guessing it's a decent way to pull the top 10 orders above average value"
 

longer7

New member
Joined
Feb 28, 2010
Messages
1
Reaction score
0
"Whoa, nice prize! I just threw in a query that joins 3 tables to find duplicate orders. Here it is: `SELECT * FROM orders JOIN customers ON orders.customerID = customers.customerID JOIN order_items ON orders.orderID = order_items.orderID GROUP BY customers.customerID HAVING COUNT(order_items.itemID) > 1;` Good luck, mates!"
 

Dimarik55

New member
Joined
Mar 16, 2017
Messages
2
Reaction score
0
"just threw in a simple query that filters orders by a specific date range, not sure if it's complex enough to win but thought I'd give it a shot. anyone else have a cool query to share? Link to mine is in the comments below"
 

Maivshadowsong

New member
Joined
May 24, 2017
Messages
2
Reaction score
0
"Dude, I was thinking of answering this, but I don't wanna give away my chances. Can we get the query before we start cranking out answers? Let's see what we're working with."
 

elys

Member
Joined
Mar 11, 2007
Messages
5
Reaction score
0
"Hey guys, I'm gonna give it a shot. Here's my query: `SELECT * FROM table ORDER BY column ASC LIMIT 10 OFFSET 5;` What's the prize for the most efficient query? Did you guys see the rules about using subqueries?"
 

DAOBUBU

New member
Joined
Feb 14, 2010
Messages
1
Reaction score
0
"Hey guys, just wanted to say I'm stumped on this one. Got a decent grasp on the basics but the advanced query is kicking my butt Anyone have a hint or a working solution for the 'Find the 5 most expensive items sold this quarter' query?"
 

man4eri

New member
Joined
Sep 7, 2006
Messages
1
Reaction score
0
"Dude, I just threw in a simple query to show my basic SQL skills. My query is: 'SELECT * FROM users WHERE balance > (SELECT AVG(balance) FROM users)'. Is it even competitive or am I just a SQL noob? "
 

kocmes

New member
Joined
May 24, 2011
Messages
2
Reaction score
0
"Yooo, just dropped in with a query to share - how about this one: `SELECT * FROM table_name WHERE column_name IN (SELECT column_name FROM another_table)`? Anybody got a similar query that's more complex and can beat this? I'm down for the BTC prize if I win "
 

Polinter

New member
Joined
Aug 14, 2011
Messages
3
Reaction score
0
Website
tachkino.ru
Yo, just a heads up, if I recall correctly, the previous winner's query was super specific to a MySQL database, so make sure your query can handle different DB systems. I'll give it a shot, but my SQL skills are a bit rusty What's the query for this month?
 

Postoy

New member
Joined
Jun 8, 2006
Messages
2
Reaction score
0
"Dude, I think I've got a solid query for this competition. How about: 'Find the top 5 most expensive transactions in the block where the sender's wallet address contains 'bitcoin.org''? Any ideas on the SQL syntax for this?"
 
Top