[257] Missing Records in SQL

Back to General discussions forum

Signum_X     2025-05-08 16:40:17
User avatar

Hi,

I think the requirement of this problem is either not stated clearly or most likely is that the submit checker does not work correctly.

From what I understood the requirement is to give the trackcodes of the packages which have attempts with just one event with status "created".

I wrote such query but I am getting this error at submit ("Thanks for your Submission Attempt" window) like this:

Less [or More] results than expected for:
create table package ... [think some input test data pasted here]

Also the tables given above do not correspond to what is shown when you click on "Your Input Data" in the same window.

My theory is that the input data given to users's query is not the same with the input data that the server uses to check the users's answer, if someone could please check.

Thank you.

gardengnome     2025-05-08 16:58:37
User avatar

My solution just passed. Solutions are not just those packages with one created event ...

Signum_X     2025-05-09 05:50:08
User avatar

Thanks, gardengnome, I see though I am trying all kinds of attempts and still do not understand the requirement, this statement also confuses me in the problem:

...which have no any events, except "created"...

So does that mean:

  • which have no events, except created ("any" is typo)
  • which have any events, except created ("no" is a typo)
  • which have no other events, except created ("any" should have been "other", though similar in meaning with first case)

Also, the error regarding "more" or "less" results then expected is given even if there is a syntax error.

Another thing which is not specified, the tracking numbers should be sorted in any way? Maybe I gave the correct response in one of my attempts but not in the correct order.

gardengnome     2025-05-09 12:56:10
User avatar

... which have no events unless the events are created events.

  • Case 1: have no events
  • Case 2: have events => those events are created events

... which have no events that are non-created events.

Signum_X     2025-05-11 16:00:22
User avatar

Thanks for the tip gardengnome but still I am missing something.

So basically events which are not 'created' are NOT of interest from what I understand, or is there something more?

Is there an order of any kind needed for the result?

gardengnome     2025-05-11 16:06:01
User avatar

Think about the following two sets:

  • S1: set of track codes of all packages
  • S2: set of track codes of all packages that have a non-created event

For this problem, how do you have to combine these two sets to get the answer?

Signum_X     2025-05-12 07:16:59
User avatar

I tried this a hundred times already in all kinds of combinations but still failing.

Let me give you the cases I see and if I return the corresponding trackcode or not:

  1. package with no attempts -> YES
  2. package with attempt which has no events -> YES
  3. package with attempt which has only one created event -> YES
  4. package with attempt which have multiple events, including a 'created' one -> NO
  5. package with attempt which have multiple events, excluding a 'created' one -> NO

I should mention that I tried all kinds of combinations of these, the one above is what I believe should be correct but I did not try ALL possible combinations though I guess I'll go ahead and do that since there are not so many.

Any other case I am maybe missing?

gardengnome     2025-05-12 07:58:16
User avatar

I have just tested an updated solution that uses the EXCEPT operator on:

  • Query that returns the track codes of all packages
  • Query that returns the track codes of all packages that have (at least) one non-created event.

I hope that gives a clue. I suspect that you might have a small implementation issue with the logic described above.

Signum_X     2025-05-12 09:05:02
User avatar

Wow so I tried using except as you said and it passed, then also used without except applying the same logic and it worked.

Indeed there was a very subtle logical difference in what I was doing.

I was selecting packages which have attempts that do not have non-created events.

Instead of to select packages which do not have attempts that have non-created events.

Thanks for sticking around to help me out, gardengnome! Hope this helps someone else who has issue with this one.

Please login and solve 5 problems to be able to post at forum