Viewing 15 posts - 2,146 through 2,160 (of 5,504 total)
Wouldn't the following return the same result?
;WITH cte AS
(
SELECT
ID,
R_DATE,
CATEGORY,
ROW_NUMBER() OVER (PARTITION BY SHRNCRS_NCST_CODEORDER BY R_DATE DESC) Rno
FROM STABLE
WHERE SHRNCRS_NCST_CODE IN('CC', 'MB')
)
SELECT *
FROM cte
WHERE Rno=1
January 10, 2011 at 12:58 pm
You could either use a subquery with MAX() and GROUP BY or change the PARTITION BY part in your ROW_NUMBER subquery and use it directly against your source table.
As a...
January 10, 2011 at 11:56 am
It's just not as easy as you might think to work on such a rather large query without any sample data to play with ... 😉
All we have is the...
January 10, 2011 at 10:49 am
Would a simple REPLACE(YourValue,'%','') do the trick?
January 10, 2011 at 7:22 am
JMSM (1/9/2011)
Thanks a lot LutzM.I'll change the function as u tell me.
Regards,
JMSM 😉
The function issue is not the only problem (might not even be the most relevant one).
So, please follow...
January 9, 2011 at 6:07 pm
GROUP BY is used to perform aggregation.
So you'd need to add every column of your SELECT statement where you don't perform any sort of aggregation (min, max, avg, sum, count).
That...
January 9, 2011 at 11:44 am
There are several approaches you can use:
Most important:
instead of applying a function to your columns rewrite it as SARGable arguments:
datediff(d, i.LstMdfation, getdate()) < 30
-- would be
i.LstMdfation>dateadd(dd, -30, getdate())
Another...
January 9, 2011 at 7:26 am
sandeepmittal11 (1/9/2011)
Check out this link<a href="http://itdeveloperzone.blogspot.com/2010/12/display-column-of-different-rows-as.html">Display column of different rows as column of a single row</a>
Did you realize this thread is almost two years old?
And the link you posted shows...
January 9, 2011 at 6:25 am
A few things to notice:
When running queries against datetime values stored in your db you should not convert those values to varchar in order to do any comparison. This will...
January 9, 2011 at 4:14 am
Here's something that should get you started.
A few things to notice:
Instead of using an on-the-fly tally table you should considerto build a permanent one. It's quite helpful in many scenarios,...
January 9, 2011 at 3:57 am
I just tried to print your dynamic statement and it returned:
SELECT emp_id, emp_name + COALESCE(NULLIF('(' + COALESCE(CAST(emp_number AS varchar(10)),') +')','(' + ')'),') AS display_name from Employee ORDER BY emp_name
It seems...
January 8, 2011 at 1:19 pm
Why don't you use a foreign key concept and the cascade delete option?
January 8, 2011 at 1:03 pm
Are the data in your [ProctorSlot] the time spans already reserved?
If so, you could use a calendar table together with a tally table to get your "N" min interval.
I don't...
January 8, 2011 at 1:02 pm
Yep, Tuning Advisor to provide some "hints" is about all that's available with SS2K.
Isn't it amazing, how little time is needed until we forget how hard it was to tune...
January 8, 2011 at 12:55 pm
It depends on what you're looking for...
I'd use ROW_NUMBER istead of RANK. This will return values 10 and 11 for 'Top 7 Raw'.
January 7, 2011 at 4:43 pm
Viewing 15 posts - 2,146 through 2,160 (of 5,504 total)