6 kyu
Analyzing the sales by product and date
2,135 of 2,134FArekkusu
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
I'm stuck at the monthly/yearly totals. I can get the daily totals, but dont know how to insert the others.
This comment has been hidden.
This comment has been hidden.
Your solution is not correct. Note how the output table wants you to have a row for each day that the item was sold, and then a row with the total for each month it was sold, and then a row for each year that it was sold, and then a row for the total overall sales of the item... and then you have to have all of those rows for each item. That's why the expected solution is so much longer than the one your query generates. Your query is not correct.
Resolved, since then user has solved this kata & diffrence not caused by a kata issue.
An error occurred while loading ./main.rb. Failure/Error: prepare_sample_data
NameError: undefined local variable or method `prepare_sample_data' for main:Object
./spec.rb:1:in `<top (required)>'
./main.rb:32:in `<top (required)>'
No examples found.
What is this error?
I check the solutions, copy the best sol, go back and paste it, run it. ERROR!! This kata has obviously smth wrong
The tests are expecting totals in scientific notation, but the sample tests do not. So which one should it be? And the test is somehow timing out...
Scientific notation is used for representing
numeric
values but the expected values in the sample tests were regular floats. The description clearly says which should be used but I changed the sample tests for uniformity and to follow the spec.I think this was caused by too much stuff being written to stdout/stderr on failure. I've changed the random tests to generate less data, and now your solution doesn't time out.
This comment has been hidden.
The error message clearly says what's wrong. You should read the documentation about how to use
GROUP BY
and aggregate functions correctly.This comment has been hidden.
This comment has been hidden.
Ranks can't be changed easily anymore.
Do you maybe know why with using to_char(date, 'YYYY')::int etc which result in good output, the whole result didn;t work, I had to use extract
I feel like if the instructions explained how to insert the month an year totals, that would bring it down to a true 6.
I agree with this
Nice kata. Unfortunately, my solution runs in the console error "Max Buffer Size Reached (1.5 MiB)". The test is all green. But the "Attempt" fails with this error. I think there are too many rows returned and printed.
This comment has been hidden.
No, the buffer size didn't change. I think the
expected
tab can sometimes consume all of the available space (even though I haven't encountered this myself) since its content is not truncated to the first 100 rows like it happens for theactual
tab. Anyway, I replaced the CW-provided testing function with the custom one I use, which I somehow forgot to do while updating all of my SQL katas earlier, so this shouldn't happen anymore if your solution is fully correct; otherwise, it'll still output the whole table, both onactual
andexpected
tabs.this one was disgusting
The test-data seems to be have gone missing.
I went for a solution with unions and couldn't manage to pass 3 tests:
"year" column should be a Fixnum value
"month" column should be a Fixnum value
"day" column should be a Fixnum value
Can anyone please help ?
year
,month
, andday
are supposed to beint
's but your solution returns them asdouble
's.It worked. Thank you!
This kata deserves higher ranking
5kyu i think
This comment has been hidden.
Without seeing the actual input it's impossible to tell which is right and which is wrong. The random tests generate a huge amount of entries, and I doubt that you could end up with only 1 day of sales in a month. Considering there're already hundreds of kata completions, closing.
Also, I can see your solution, and your
JOIN
's are incorrect, so that's definitely a problem on your side.Thanks for the reply
Has anyone found missing data issues when running their query?
I've got 10/12 steps correct and was able to get the total revenue broken down by year, month, and day.
The two errors I'm running into are
Rows expected: 5313 got: 4999
Actual and expected tables don't match perfectly (even when it appears they do)
Appreciate any guidance I can get.
Thanks!
This comment has been hidden.
hehehee same. and thinking while I was implementing my huge repetitive code with uninon "there's no way there isn't a better way to solve this"
This comment has been hidden.
This comment has been hidden.
Is any possibility to format the part of question as the code?
You're not returning the totals. For example, instead of
you only return
There's a certain language feature which lets you easily generate these.
I have the same problem. The year, month and day are not treated as separate columns.
This comment has been hidden.
This comment has been hidden.
Great Kata, you might consider switching the "profit" wording to "revenue" though. Profit implies a subtraction of cost
In both sample tests and actual tests:
Another row with all values empty is expected.
Should be working now.
;-)
I'm having the same issue. It doesn't like the grand total row at the end of my results.
→ ,sausages ,2018,NULL ,NULL,66712.7999999999→66712.8
There are floating point errors in the actual tests. Shouldn't
price
be of typedecimal
anyway since it's currency data?Made input
price
and outputtotal
of typenumeric
.;-)