Viewing 15 posts - 136 through 150 (of 4,087 total)
I was thinking along the same lines as Jeff, but did things in a slightly different order. By uniquifying first, I'm able to use the current price for the previous/next...
April 25, 2023 at 1:32 pm
It's not clear what you are trying to accomplish here. And based on best guesses there are several issues.
April 24, 2023 at 4:13 pm
This is a much shorter template and is thus easier to understand. It's also probably more efficient, because it will abort as soon as it finds ANY row that contains...
April 20, 2023 at 8:32 pm
SELECT Student_ID
FROM dbo.table_name
GROUP BY Student_ID
HAVING MAX(CASE WHEN Student_Status = '2' THEN 1 ELSE 0 END) = 1 AND
MAX(CASE WHEN Student_Status <> '2' THEN 1...
April 11, 2023 at 2:30 pm
The fields listed in the SELECT
clause are a subset of the fields in the GROUP BY
clause. What you said about DISTINCT
is only necessarily true if...
April 11, 2023 at 2:08 pm
Why are you using DISTINCT
and GROUP BY
in your first query out of interest? GROUP BY
already puts your data into distinct groups, so the DISTINCT
in the...
April 11, 2023 at 1:52 pm
Both tables contain a chain id, store id, supplier id, and product id. I would expect that you would want to include EACH of those columns in your join criteria.
I...
April 11, 2023 at 1:48 pm
something along these lines - it assumes that none of the duplicates already contain a row that is 1 hour ahead
if object_id('tempdb..#keys') is not null
...
April 4, 2023 at 7:50 pm
Instead of the wordy
If(OBJECT_ID('tempdb..#TBL_Orders ') Is Not Null)
Begin
Drop Table #TBL_Orders
End
I recommend switching to the shorter and more intuitive
DROP TABLE...
April 4, 2023 at 6:23 pm
I think you are looking for something like the following:
WITH Server_Databases AS
(
select a.Server,d.dbname [DB_name], COUNT(d.dbname) OVER(PARTITION BY a.Server) AS cnt
...
March 28, 2023 at 12:59 pm
First, when you post code, you should use the {;} Code
button to format the code.
The simplest (but not necessarily most efficient) method is to use nested queries.
March 23, 2023 at 4:00 pm
Instead of dividing by 100 try dividing by 100.0. With division the implicit type conversion is to INT unless the denominator is non-INT, either NUMERIC or FLOAT. Also, imo...
March 23, 2023 at 2:30 pm
You might also check the encoding of the old and new versions. I know that Notepad++ will show you the encoding.
Drew
March 23, 2023 at 1:29 pm
I don't use Jeff's string splitter, but this is the broad outline.
March 23, 2023 at 1:22 pm
You're doing integer division, which is why you're getting 0's. Instead of specifying 1
(integer), specify 1.0
(decimal).
Also, you don't need the ISNULL()
if you specify the CASE
expression correctly.
March 23, 2023 at 1:03 pm
Viewing 15 posts - 136 through 150 (of 4,087 total)