GithubHelp home page GithubHelp logo

sql-exercise's Introduction

SQL-exercise

Schemas, Questions & Solutions for SQL Exercising

Introduction

The schemas and questions are

[1] from Wikibook SQL Exercises [https://en.wikibooks.org/wiki/SQL_Exercises]. Solutions are from both this Wikibook and me (exercise 1-8). I also added some questions by myself.

or

[2] given by me using some practical examples I encountered (exercise 9-10).

Repository Structure

The repo structure is like below:

SQL-exercise
└───SQL_exercise_1
└───......
└───SQL_exercise_*
    │   *_schema_figure.png
    │   *_build_schema.sql
    │   *_questions_and_solutions.sql

└───......

License

Please note this repostory is under the Creative Commons Attribution-ShareAlike License[https://creativecommons.org/licenses/by-sa/3.0/].

sql-exercise's People

Contributors

analysthub-hub avatar avoyan avatar fernandosoto138 avatar moralesfelipe avatar peng0723 avatar rudrigous avatar xd-deng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sql-exercise's Issues

maybe there is something with -- 1.16

it should be :
select p.name,m.name,p.price from products p join manufacturers m on p.manufacturer = m.code where p.price in (
select min(a.price)
from Manufacturers b join Products a
on a.Manufacturer = b.code
group by b.name);
Your answer always showes the wrong product name to match the price.

Reorder some things

I saw this repo and it's great how much exercises are.

It would be great what the exercises are separated from solutions.

If you accept pull request, I offer myself to do that work.

Better solution for Question no 1.16 in 1_questions_and_solutions.sql (SQL_exercise_01).

I have a better solution for Question 1.16 in SQL_exercise_01 which can solve the query in just 2 lines.

My solution:

select b.name, a.price, a.name
from products a join manufacturers b on (a.Manufacturer= b.code )
where a.price in (select max(price) as p from products group by manufacturer order by max(price) );

just

Current solution:

select max_price_mapping.name as manu_name, max_price_mapping.price, products_with_manu_name.name as product_name
from
(SELECT Manufacturers.Name, MAX(Price) price
FROM Products, Manufacturers
WHERE Manufacturer = Manufacturers.Code
GROUP BY Manufacturers.Name)
as max_price_mapping
left join
(select products.*, manufacturers.name manu_name
from products join manufacturers
on (products.manufacturer = manufacturers.code))
as products_with_manu_name
on
(max_price_mapping.name = products_with_manu_name.manu_name
and
max_price_mapping.price = products_with_manu_name.price);

orignal

Solutions for Exercise 8

Hi,

These are way helpful exercises. Thank you so much.
Can you please upload the solutions for Exercise 8. I couldn't find one !

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.