Viewing 15 posts - 91 through 105 (of 4,087 total)
Thanks for your feedback Phil,
The reason for the layout of my sample data was just for simplicity. I inserted my sample data into a physical table and then just...
October 11, 2023 at 3:38 pm
Here is what I came up with. If I had more time, I'd rewrite it to use closed-open intervals rather than open-closed intervals. (That is, I'd include the start date,...
October 10, 2023 at 6:14 pm
I prefer to use OFFSET/FETCH NEXT
to run batches of records in a loop. I've updated your query to reflect that.
October 5, 2023 at 5:14 pm
How are you ordering the data? I do not see what makes the second row come after first.
I didn't see anything specifying a filter based on order. The OP...
October 5, 2023 at 4:19 pm
When posting sample data to the web, you do not need to post EVERY SINGLE FIELD IN YOUR TABLE. More importantly, you could be in trouble for posting PII
October 3, 2023 at 2:36 pm
Any data type can be converted to binary, and it's impossible to tell from what you have given us what data type to convert back to. I tried VARCHAR, NVARCHAR,...
September 28, 2023 at 4:28 pm
drew.allen wrote:SELECT STRING_AGG(QUOTENAME(td.[name], ''''), ',')
FROM #tbl_db AS td;I prefer using CHAR instead of multiple single-quotes:
SELECT STRING_AGG(QUOTENAME(td.[name], CHAR(39)), ',')
FROM #tbl_db AS td;
I can never...
September 26, 2023 at 9:08 pm
SELECT STRING_AGG(CONCAT('''',td.name,''''),',')
FROM #tbl_db td
Instead of using CONCAT()
use QUOTENAME()
, in case your text contains single quotes. It will automatically create escaped forms of single quotes in...
September 26, 2023 at 2:10 pm
For a running total - you can use: thisBalance = SUM(thisAmt) OVER(PARTITION BY Batch_Id ORDER BY Id)
If you want to break out the totals even further, add those to...
September 17, 2023 at 7:05 pm
I've updated the code to a) use a temp table instead of a permanent table. Here is the setup code:
DROP TABLE IF EXISTS #charges;
CREATE TABLE #charges (
...
September 14, 2023 at 8:53 pm
The problem is the issue_id. Just remove it from the GROUP BY. I used it in the GROUP BY, because it was in your original query.
Also, if your master_ind is...
September 12, 2023 at 8:02 pm
There are two potential solutions depending on whether the child records have the same category_id and ldk_id as the master record. (NOTE: this is where sample data would be REALLY...
September 12, 2023 at 3:09 pm
This gives you the expected results. You'll probably need to feed the CTE into a MERGE statement to get the updates that you need.
WITH Temp_Changes AS
(
...
September 7, 2023 at 3:42 pm
For best performance, you want to stop using NULL so you don't have to do ISNULL() as part of the WHERE. Yes, you will have to go back and...
August 25, 2023 at 7:44 pm
Your ValidFrom
and ValidUntil
are DATETIME2(7). GETDATE()
returns DATETIME, so you have a mismatch in the precision. Try using SYSDATETIME()
instead of GETDATE()
.
Drew
August 24, 2023 at 5:19 pm
Viewing 15 posts - 91 through 105 (of 4,087 total)