Viewing 15 posts - 241 through 255 (of 4,085 total)
I'm not sure if this is more efficient, but this also works.
SELECT PackageName = 'Project'
,ItemType = 'Project Parameter'
...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
May 27, 2020 at 1:46 pm
This sounds like something that should be done in the presentation layer, not the data layer. This is easy in SSRS, for example.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
May 18, 2020 at 1:46 pm
You have your dates switched in the DATEDIFF function. It should be DATEDIFF(DAY, LAG(...), visit_date_01). Or you should be using LEAD() instead of LAG().
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
May 4, 2020 at 4:00 pm
Use the TRY_CONVERT() or the TRY_CAST() function. They will return the value if it can convert/cast it, and will return NULL otherwise.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
May 4, 2020 at 1:40 pm
Certain windowed functions that use an ORDER BY clause require a frame. If you do not provide a frame it uses the default RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. ...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 30, 2020 at 6:54 pm
First, most people are hesitant to open attached files from random strangers on the net. You should provide scripts using the {;} Insert/edit code sample button just above the text...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 29, 2020 at 8:37 pm
And why does the col2 value switch from ab to dd on 08/04/2020?
It looks like you want a DENSE_RANK(), but the exact details depend on your answer to Phil`s question.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 29, 2020 at 7:13 pm
Based on Neil's sample data, here is a first attempt at a query.
SELECT c.Name, c.NameKey, c.SaleDate, c.SaleQuantity, c.CurrentCategory, h.Value
FROM #Current c
OUTER APPLY
(
SELECT TOP(1) *
FROM #History h
WHERE h.NameKey...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 13, 2020 at 7:17 pm
You've been around long enough to know that you should provide sample data and expected results.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 13, 2020 at 7:07 pm
A picture of your data is worthless. You need to supply actual data by supplying a script using the {;} Insert/edit code sample to do the following.
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 13, 2020 at 2:16 pm
We don't have enough information to tell you exactly what the problem is, but the error message gives you a LOT of information.
dbo.ItemDetail has a primary key...J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
February 28, 2020 at 7:00 pm
If there are no updates (impossible without a key) or deletes, I would suggest not using MERGE, but INSERT:
INSERT target (cols)
SELECT cols FROM source
WHERE NOT EXISTS...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
February 27, 2020 at 3:48 pm
Please do not cross post. Please respond on this thread https://www.sqlservercentral.com/forums/topic/need-help-parsing-xml-3#post-3727725
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
February 21, 2020 at 3:48 pm
Sometimes a backslash is used to insert a literal character. It looks like whatever produced this XML hypercorrected and used \" to insert a literal double quote (") when it...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
February 21, 2020 at 3:47 pm
The issue that you're running into is that the two separate queries have different criteria and you aren't taking that into account when you are combining them into one query. ...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
February 12, 2020 at 9:26 pm
Viewing 15 posts - 241 through 255 (of 4,085 total)