April 20, 2015 at 10:31 am
I need a column in my query results that just numbers the rows sequentially (i.e. 1, 2, 3). How can I do that? Thanks.
April 20, 2015 at 10:33 am
With ROW_NUMBER. https://msdn.microsoft.com/en-us/library/ms186734.aspx
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 20, 2015 at 10:45 am
Thank you
April 20, 2015 at 6:23 pm
With regards to your thread's subject:
The only stupid query questions are the ones you don't ask.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
April 20, 2015 at 8:58 pm
dwain.c (4/20/2015)
With regards to your thread's subject:The only stupid query questions are the ones you don't ask.
Lol I feel like it was an easy question but I'm also a programmer having to pretend to also be a dba and a network engineer.
April 20, 2015 at 9:01 pm
Sean Grebey (4/20/2015)
dwain.c (4/20/2015)
With regards to your thread's subject:The only stupid query questions are the ones you don't ask.
Lol I feel like it was an easy question but I'm also a programmer having to pretend to also be a dba and a network engineer.
-- We speak in SQL-tongue here
DECLARE @LowHangingFruit BIT;
SELECT @LowHangingFruit=AnyQuestion
FROM AnyTopic
WHERE simple <> dumb;
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
April 20, 2015 at 9:19 pm
dwain.c (4/20/2015)
Sean Grebey (4/20/2015)
dwain.c (4/20/2015)
With regards to your thread's subject:The only stupid query questions are the ones you don't ask.
Lol I feel like it was an easy question but I'm also a programmer having to pretend to also be a dba and a network engineer.
-- We speak in SQL-tongue here
DECLARE @LowHangingFruit BIT;
SELECT @LowHangingFruit=AnyQuestion
FROM AnyTopic
WHERE simple <> dumb;
-- We speak in SQL-tongue here
DECLARE @LowHangingFruit BIT;
SELECT @LowHangingFruit=AnyQuestion
FROM AnyTopic
WHERE 'simple' <> 'dumb';
:-P:-P:-P
-- Itzik Ben-Gan 2001
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply