M
M
makaron7102020-12-25 18:08:16
SQL
makaron710, 2020-12-25 18:08:16

Online database for training. Or how to check the request?

Good day!
I'm doing a test task for a potential employer.
There is a task, there is a data scheme, there is a solution that needs to be checked.
To check the correctness of the request, you can make a local database and fill it, but most likely it will not be possible to take into account all possible pitfalls in the data set.

Are there online databases to test a query against a table with the following structure?
5fe5ff067d389799969502.png
________________________________________________________________________________________________________
Or perhaps someone will find blunders in my request? And then I will forget about the test task and first go to pump my skills in sql.

Task:
Using the above database schema, create a query that displays a list of brands
(brand.name) indicating the number of product units in descending order of their number in
each warehouse for the current brand. It should be taken into account that for some brands there
may be no goods in stock for a unit of time, while such brands
should also be included in the output. Absence means the absence of a product entry in the goods table
, and not a zero quantity.

Decision:

select brand.name, goods.quantity
from brand left outer join product 
  on brand.id = product.brandId
left join goods
  on product.id = goods.productId
order by goods.quantity desc


Thank you for your attention!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
Gleb Starkov, 2020-12-25
@colonel

sql fiddle

L
Lazy @BojackHorseman, 2020-12-25
SQL

no way. You will have to fill in the data yourself.
for training there is sql-ex.ru. there, the second test base takes into account all the options and does not disclose details, so you have to calculate the cases yourself.

V
Vladimir Korotenko, 2020-12-28
@firedragon

There are cheap vps from 90 rubles a month.
There are virtual machines. My advice is to deploy the instance locally. Better even absolutely with the environment that the client will have.
Project structure:
/bin - your various scripts
/sql - root folder for all queries
/sql/version/up - version is the bug number or issue in the bug tracker, up is scripts for migration from the previous version
/sql/version/down - migration to previous version
/sql/version/test - test data
... something else

K
KingAnton, 2017-02-20
@KingAnton

Don't forget to substitute your post type for 'auto'

function remove_post_slug( $post_link, $post, $leavename ) {

    if ( 'auto' != $post->post_type || 'publish' != $post->post_status ) {
        return $post_link;
    }

    $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );

    return $post_link;
}
add_filter( 'post_type_link', 'remove_post_slug', 10, 3 );


function parse_request_trick( $query ) {

    if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
        return;
    }

    if ( ! empty( $query->query['name'] ) ) {
        $query->set( 'post_type', array( 'post', 'auto', 'page' ) );
    }
}
add_action( 'pre_get_posts', 'parse_request_trick' );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question