Viewing 15 posts - 4,576 through 4,590 (of 5,394 total)
max(seq) over (partition by street)
returns the maximum sequence number in each street group.
In case of ties between different streets, you order by street.
Inside each street group, you want the...
February 22, 2010 at 3:16 am
You probably need to keep the streets together. Try adding street in the order by in 2nd position:
select *
from @jobs
order by max(seq) over (partition by street) desc, street, seq...
February 22, 2010 at 2:55 am
To understand the query you just have to add the order by column to the select list:
select *, max(seq) over (partition by street) as maxseq
from @jobs
This returns the max sequence,...
February 22, 2010 at 2:44 am
select * from @jobs
order by max(seq) over (partition by street) desc, seq desc
Hope this helps
Gianluca
February 22, 2010 at 2:20 am
This should do the trick. There must be some quicker way, but for a one time search it should work.
DECLARE @searchString varchar(100)
DECLARE @searchStringEscaped varchar(100)
SELECT @searchString = ' XYZ_',
@searchStringEscaped = '%...
February 22, 2010 at 2:06 am
You can do it yourself: https://www.sqlservercentral.com/MyAccount
February 22, 2010 at 1:41 am
Thanks Gus. I'll be sure to test it, obviously.
I read on a quite old article that partitioning makes reads worse, but improves writes. Is it true in your experience?
Also, will...
February 18, 2010 at 11:32 am
GilaMonster (2/18/2010)
Some threads lately there's been so much conflicting advice from various people that it's hard to get useful...
February 18, 2010 at 9:49 am
jcrawf02 (2/18/2010)
Grant Fritchey (2/18/2010)
February 18, 2010 at 9:42 am
GilaMonster (2/18/2010)
Gianluca Sartori (2/18/2010)
In that particular case, with the identity column as primary key clustered, yes, doesn't it?
Logical order of the index - yes
Physical order of the data - no
Order...
February 18, 2010 at 4:19 am
Dave Ballantyne (2/18/2010)
Does anyone else read this responsehttp://www.sqlservercentral.com/Forums/FindPost867131.aspx
as implying that using a identity defines order ?
In that particular case, with the identity column as primary key clustered, yes, doesn't...
February 18, 2010 at 2:24 am
It could be a date format issue. Your code is also prone to sql injection, use prepared statements instead.
Put @parameter placeholders in your sql, then add parameter values to your...
February 18, 2010 at 2:05 am
Looks like somebody can't stay away from corruption threads...
http://www.sqlservercentral.com/Forums/FindPost867727.aspx
I foresee SSIS being mentioned 😀
February 18, 2010 at 2:01 am
It's hard to tune a query without table definition scripts and indexes.
That said, you could try to get rid of one of the outer joins in your view:
CREATE VIEW [dbo].[viMostRecentPatientEvent]
AS
SELECT...
February 16, 2010 at 2:26 am
Viewing 15 posts - 4,576 through 4,590 (of 5,394 total)