The Heap™ – Consultancy ©®

General on- and off-site discussion for dba.stackexchange.com....
Oct 25, 2021 09:27
@HannahVernon Thanks
 

  Trash

DELETE FROM "The Heap" WHERE message IS NOT DISTINCT FROM tras...
Aug 23, 2021 11:31
Anyway, there seems to be quorum enough here, I'm out
Aug 23, 2021 11:30
Maybe some dumb bot sent the invitations based on that ^^^
Aug 23, 2021 11:29
Aug 23, 2021 11:29
I might be wrong
Aug 23, 2021 11:25
I'm more inclined to think I was invited by a human though, rather than by some automated system for whatever reason
Aug 23, 2021 11:22
@JohnK.N. Never happened before but maybe something changed recently, who knows.
Aug 23, 2021 10:53
Hi. Got an invitation to come to this room, anyone know what about?
 
Jun 8, 2021 09:34
@Vérace Thanks for the explanation, I'll try a safer option next time :) At least the one you went for (дякую, друже) was perfectly colloquial and appropriate for the occasion, well done!
Jun 8, 2021 08:58
@Vérace Wow, your answer is a lot more detailed than mine. Thanks for sharing! And-uh – I gcónaí sásta, teacht arís! (hope there's no insult in there somewhere)
Jun 8, 2021 07:13
@Vérace Hey Vérace, I've posted my answer. Feel free to catch up whenever it's convenient for you :)
Jun 7, 2021 19:26
Great, voted to reopen
Jun 7, 2021 19:22
@JOSHW Hey Josh. Your update seems to mention all the points I consider most relevant to the problem. I have one question though. Do you think #1 should specifically talk about rows where PLAN_LENGTH=12? My understanding is that in the end you want to process all the plans according to their lengths
Jun 7, 2021 18:40
@Vérace Not sure what you mean. I can see no recent changes
Jun 7, 2021 11:12
@Vérace Most likely I will, no problem
Jun 7, 2021 11:10
@Vérace I honestly don't think waiting is necessary but not going to argue :)
Jun 7, 2021 09:34
@Vérace Fiancees tend to be right in these matters, so by all means make sure she's happy first :) I'm fine with whatever time you find convenient. I'm keeping an eye on the question anyway, and if you notify me of the change, that's even better, so it's all fine by me
Jun 6, 2021 13:19
I was struggling with syntax a bit, so maybe some things could be expressed better, but that query shows best what I actually was trying to do, it's just that T-SQL is a little lacking to make the result as elegant.
Jun 6, 2021 13:17
Anyway, here's something for dessert – a Postgres solution. Mine was essentially an attempt to emulate it, as much as absence of a generate_series option in T-SQL allowed me
Jun 6, 2021 13:11
So that's why I'd prefer if either the OP or any native English speaker did the editing (as long as they understand the question, of course)
Jun 6, 2021 13:03
The edit may need to be drastic and that's what makes me doubt whether I can do it correctly, both in terms of really improving the question and in terms of keeping the OP happy about their own effort invested into it (I mean, I wouldn't want to discard too much if it can be helped).
Jun 6, 2021 12:59
@Vérace Again, I would be more at ease if we also made the question clearer. I don't mind voting right now, I'd just prefer to vote for an already improved version of the question. I'm not sure how to go about it correctly if I were to do it myself. Even if I were sure enough that my synopsis, as the OP put it, would be clear enough for most readers, I still don't know how to incorporate it, that is, how much of the original description should be left, and would it need to be rearranged etc.
Jun 6, 2021 12:54
I got carried away like that, sorry
Jun 6, 2021 12:54
Yes, I think it's predominantly SQL Server jargon to call them batches
Jun 6, 2021 12:31
@Vérace I think the condition in #5 was more correct, because it resulted in only one row for 75491773,AMT00004, which matches the OP's expected result. The condition in #6 gave you two.
Jun 6, 2021 12:17
In other words, one of the uses of CROSS APPLY for me (and I think for many other people as well) is to generate calculated columns like that, so that you can reference the columns multiple times in the query, like in this case I'm using the result of the expression both in the SELECT and in the WHERE. If I didn't need to use it twice, I'd just calculate it in the SELECT, like in my last fiddle.
Jun 6, 2021 12:13
I'm using CROSS APPLY for it because I'm referencing the date more than once, that's basically the main reason. Without it the query would look like this
Jun 6, 2021 12:10
Namely the date calculation
Jun 6, 2021 12:10
The CROSS APPLY isn't necessary, strictly speaking. It's there just to avoid repeating some code
Jun 6, 2021 12:07
You know, I think our solutions aren't totally unlike each other. There are differences in filtering but I can see that fundamentally our approaches are similar
Jun 6, 2021 12:06
Ohhh, I can see the confusion now. By batches I meant scripts in a fiddle, not the batches/groups of group_id, plan_id.
Jun 6, 2021 11:26
@Vérace Oh, and my solution is here: dbfiddle.uk/…
Jun 6, 2021 11:19
Jun 6, 2021 11:19
@Vérace I can't see any batch numbers there but that's all right. Here, take a look at this:
Jun 6, 2021 10:16
@Vérace Do you realise that batch 5 and batch 6 have slightly different conditions in the CTE's recursive leg's WHERE?
Jun 6, 2021 10:02
I posted my reply to you 19 minutes later
Jun 6, 2021 10:02
Jun 6, 2021 09:55
which is UTC+03 right now
Jun 6, 2021 09:55
I'm still at the good old EET/EEST
Jun 6, 2021 09:54
@Vérace What do you mean 03:00 your time? How could that be?
Jun 6, 2021 09:54
@Vérace Hi, I am, thanks! I hope you are as well
Jun 5, 2021 16:49
@Vérace I'm happy with that. We can also use this chat. In my estimation, it's just about making sure the phrasing is clear and unambiguous. But if you mean you want to rewrite the entire post and want my opinion, and so that's why you want to post it somewhere where it can be seen in full – no problem.
Jun 5, 2021 15:39
If you feel confident you can explain the problem clearly, then maybe you could edit the question right now.
Jun 5, 2021 15:38
@Vérace Editing the question to make the problem clearer for everyone would make the task easier, I think. I wouldn't want people to rely just on our word. I think for now we should wait till the OP responds. Then we'll see what needs to be done.
Jun 5, 2021 12:46
Yes, that's exactly the approach to negotiate these things :)
Jun 5, 2021 11:57
@Vérace I'd like to see yours as well!
Jun 5, 2021 11:55
I'd be happy to edit the description myself, it's just that sometimes I come up with wordings that may not work as well for others as they do for my non-English native mind. So I'd be more happy if you did it yourself, and if/when you do, feel free to borrow from my summary as much as you see fit in case you find any bits of it helpful.
Jun 5, 2021 11:50
Perhaps it would also be a good idea to reword your description some to make sure all the requirements are included and are as clear as possible
Jun 5, 2021 11:48
If it works well for you, we can try and reopen your question, and then I'll be able to post that as an answer
Jun 5, 2021 11:47
@JOSHW Hey Josh, thanks for the reply. I've come up with a solution that seems to match all the requirements: dbfiddle.uk/…