5 kyu

SQL Basics: Simple VIEW

4,034 of 4,036matt c
Description
Loading description...
SQL
Fundamentals
  • Please sign in or sign up to leave a comment.
  • Risiewind Avatar

    The details isn't easy to get, but the kata is fine. Without comments I couldn't manage it I believe.

  • Eatkin Avatar

    I've been doing SQL for about 1 week now and this one took me a good few hours. I had to go to bed with it unsolved, but just finished first thing in the morning. Took me a while to realise what I was actually supposed to be doing, and it really annoyed me whilst nothing seemed to be going right, but I rewrote the whole query from scratch and got it done. Good learning experience, didn't even know views existed before and think they're a really useful thing to know about.

  • Klint Ist Avatar

    Terrible description of this kata! In addition to what other comments said, you need to order by id in select from created view.

  • yurywallet Avatar

    Issue number 1: The result will be shown even if you create only comment with "create view" and correct name of the view. So simply you will pass if you just write a correct select statement with additional comments which is not what is expected right?

    Issue number 2: If you create VIEW after that you need to write in edition "Select * from that_view" otherwise there will be no data selected (no rows selected). I was expecting that select statement will be generated automatically.

  • NilufarKhaydarova Avatar

    I think the attack is on SIMPLE. Might be simple view, but not a simple query.

  • lucekdudek Avatar

    This comment has been hidden.

  • g1897 Avatar

    The prices should have rounding that is mandatory. I used sqlite and could not get it to work, while it worked without issues under postgres

  • LesPaulStudio Avatar

    Probably not a 5kyu, 6 or 7

  • unikrubii Avatar

    The explanation is confusing

  • abhishekbalawan Avatar

    English used in question is pathetic

  • Patitas_de_Pollo Avatar

    Is there other way of filter rows based on information that needs to be generated throught an aggregate function which depends on declaring a certain column in the SELECT, without the need to declare said column because it shouldn´t be shown?

  • rayearths Avatar

    I used -- to comment out create view statements, submitted the code, and it actually passed through the tests. It might be worth to check if the statements are commented out or not?

  • EveRR32 Avatar

    This comment has been hidden.

  • karinac Avatar

    This comment has been hidden.

  • sqllj Avatar

    Honestly I didn't like how this question was worded. It made it very difficult for me to understand everything I needed to do.

  • leandro alves Avatar

    This comment has been hidden.

  • EezyBreezy93 Avatar

    A lot of the product names have the same product_id. I'm new to this but that doesn't make sense. Can someone explain this?

  • Polovinkin Avatar

    Remember that you need to put ; after a view creation statement, this way it will work here. Also SQLite isn't warning you about an errors of fields you put in HAVING, so beware.

  • dirtbagesq Avatar

    Needs a secondary test for comparing departments. I was able to hard code departments.id <= 3 to limit which departments are used. Knowing the current state of the data, should not allow me to hard code the answer. I assume there is a way to have a different dataset when doing final testing?

  • melanatech Avatar

    This is the most confusing challenge I have ever seen. The wording makes no sense. To sum up the previous comments below for everyone who comes after.

    1. You need to CREATE a View, then SELECT it to show data for the unit tests.
    2. You need to find members who have spent more than $1000 across ALL departments (or at least one) which have total sales of more than $10000.
    3. Your solution needs to have these required fields (in this order): ID, Name, Email, Total_spending
  • BodonFerenc Avatar

    The test randomly fails and succedes for the same SQL query :( The testing framework is not robust or cannot handle temporal views.

  • tavit111 Avatar

    FOR EVERONE WHO STRUGLE!

    1. Understanding the task: You have to pick clients who spend more than 1,000 on products that belong to departments which sold more more than 10,000 worth of products. Sort the result by clients Id.
    2. View problem: You have to comment the line where you create view, because you can't create view here by the algorithm still picking up the view key words
  • sjin3 Avatar

    Could someone explain this sentence:

    "members who have spent over $1000 in departments that have brought in more than $10000 total ordered"

    do you want member spend over $1000? and also spend over $10000?

  • Raaven Avatar

    This comment has been hidden.

  • Miss_Evi Avatar

    As others have mentioned, the VIEW part of this kata is not tested, beyond mere inclusion of the keywords. But in my opinion, the VIEW part is not nearly as important as the challenge of organizing the query itself. This kata uses a combination and expansion of several techniques found in the 6 kyu katas. I think it's a good test of whether your fundamentals are solid.

  • MTwem Avatar

    You can pass this with the create view part of the code commented out

  • eshafer Avatar

    Could you add a comma?: -- members who have spent over $1000 in departments that have brought in more than $10000 total, ordered by the members id

  • AlexeySanko Avatar

    This comment has been hidden.

  • monicafreya Avatar

    This comment has been hidden.

  • Torkel Avatar

    Great kata!

  • a126055 Avatar

    it's says "departments that have brought in more than $10000" but it should say "departments that have brought in more than $1000000"

  • rgottesdiener Avatar

    grammar issue:

    "This VIEW is used by a sales store to give out vouches to members who have spent over $1000 in departments that HAVE brought in more than $10000 total, ordered by the members id. "

  • fiercelord Avatar

    Does anyone have the image for this problem? This is not the only Kata I have looked at that has an image that is broken when I load the page. I have tried on internet explorer and firefox.

  • Lishkon Avatar

    This comment has been hidden.

  • adam-tokarski Avatar

    This comment has been hidden.

  • MayantsevIvan Avatar

    GOOD kata ! You need to be careful not to get confused

  • Keicam87 Avatar

    Hi guys,

    I am new to codewars, but i really do enjoy learning SQL with it. I spend over 30 min on this case and I still cant complete it. Well to be precise I have created the select statement perfectly to show exactly the same results as expected, but when I add create view view_name as statement it suddenly doesnt work. Any clues on what am I doing wrong ?

  • iyordanov Avatar

    This comment has been hidden.

  • pschoenfelder Avatar

    The technical challenge of this kata is good and fun, but 80% of my time was spent trying to figure out what that challenge actually is. Do I need member revenue of > $1000:

    1. in any one department that has > $10000 revenue?
    2. summed across each department that has > $10000 revenue?
    3. summed across all departments that cumulatively have > $10000 revenue?

    (for anyone looking for clarification, it's #2)

    I think using more specific language and adding an example scenario would increase the clarity, and thus overall satisfaction rating, of this kata.

  • deepanshu786 Avatar

    This comment has been hidden.

  • kevetoile Avatar

    I managed to get the good results but the attempts fails because of the lack of order precision in the instructions paragraph

  • DEMOOH Avatar

    The "total_spending" column name is kind of misleading. You have to return total spending "in departments that has brought in more than $10000" to pass the kata.

  • seansutton Avatar

    I enjoyed this one. The select query was more interesting than creating the view - it was cool to see how different people used different ways to get the result on that (CTE, subqueries, other methods).

  • bgzl Avatar

    This comment has been hidden.

  • perfectcoder Avatar

    This comment has been hidden.

  • quicksliver Avatar

    As others said the wording on this is somewhat difficult to parse. Instead of "This VIEW is used by a sales store to give out vouches to members who have spent over $1000 in departments that has brought in more than $10000 total ordered by the members id. "

    What about: "This VIEW is used to give out vouches to members who spent over $1,000 in departments that have sales of over $10,000. Results should be ordered by member id ascending."

  • pasztorb Avatar

    I've created the view and the select finally. As a result the actual rows absolutely the same as theexpected row. Even 12 passed and 1 failed. The text for the failure the next: "should should return the expected results" "expected true to respond to true? or perhaps you meant be true or be_truthy". After all I've tried choosing one from the best solutions and I've got the same bad result.

  • janca Avatar

    Is creating a second view allowed? I wanted to but seems I am having a problem reaching the server, maybe because of that...?

  • janca Avatar

    I used a second view to crack up the query into comprehensible chunks. While tests pass, seems I am having a hard time submitting this solution.

  • MorganJr Avatar

    Your Table Diagram image is being blocked by my network. I know, it's my problem (you might be saying "Well, get out of that network, noob!"). But is there a creative self contained solution in Markdown that might display Table Diagrams and Relationships without requiring embedding external images? I know it's my issue, but what do you think?

  • cflury Avatar

    The wording of the challenge is confusing for me - maybe because I'm not a native English speaker. I understood we're looking for members having spent more than $1000 in total in departments with a turnover of $10.000 or more. But you're looking for such members having spent more than $1000 in at least ONE department with a turnover of at least $10.000.

    Futhermore, there is a typo, "vourches".

  • ByteEater Avatar

    The phrase "ordered by the members id" is in a completely wrong place. The suite requires the whole result be ordered thus.

  • mmalkavian Avatar

    it seems to me that it is not possible to create "with" queries or other views beside the one requested in the instructions. is that correct?

  • omegahm Avatar

    The tests are not checking the "> 10000" brought in by the department condition.