Viewing 15 posts - 76 through 90 (of 600 total)
Ok, I have thrown together a quick sample for you.
First, an explanation.
You need to do this with dynamic sql. One query builds a string that contains your actual query,...
February 28, 2015 at 10:30 pm
Looking at your example more closely, we would also need a way to tell which columns we are unpivoting together (what is a value vs rank, what value belongs with...
February 28, 2015 at 6:50 pm
Ok, now we are getting closer. Having some background is very helpful.
I am still a bit unclear from your comment as to whether you could use one report or multiples....
February 28, 2015 at 6:43 pm
I think it might help if you took a step back and explained what you are trying to achieve overall.
Sounds like you like your query fine but want the same...
February 28, 2015 at 4:01 pm
Although you have gotten me wondering if I shouldn't add a non-clustered index on StartDate (in the Clients table)...
To solve this problem? Probably not.
If its really a 200 row...
February 27, 2015 at 3:35 pm
Hmm
You should definitely rewrite the function regardless, but based on your description of the bound form, I am not sure that even with a better function you'll be able to...
February 27, 2015 at 12:48 pm
He means that you gave us an example we can't run
Your create table creates one set of column names, and your insert references different ones.
Then you are also missing a...
February 27, 2015 at 12:20 pm
I am going to assume that your function takes awhile to run?
Lets start with what nolock does.
By default, SQL Server uses what is known as a READ COMMITTED transaction isolation...
February 27, 2015 at 11:51 am
Greg Snidow (2/27/2015)
This one would fail (or show 2 rows for one customer) if 2 rows had the same date
If the system is designed so there are not 2 rows...
February 27, 2015 at 11:29 am
muho_92 (2/27/2015)
ty it works. Is there another solutiton without using ROW_NUMBER() OVER PARTITION BY
Yes, but they are all very similar and the others likely less efficient and with potential pitfalls.
This...
February 27, 2015 at 9:47 am
SELECT id, customerid, productid, [date], quantity, total
FROM (
SELECT id, customerid, productid, [date], quantity, total, ROW_NUMBER() OVER (PARTITION BY customerid ORDER BY [date] DESC) rn
FROM Whatever_The_Table_Name_Is
) Numbered
WHERE rn =...
February 27, 2015 at 9:31 am
edit: Gold star for Stewart, whose explanation of the behaviour is more correct that Eirikur and more complete than Toreador.
February 26, 2015 at 7:53 am
So you want #a1 to have six identical rows?
It only has columns for name and unit, so all 6 would be ( 'abc', 1 ), correct?
I'm somewhat puzzled as to...
February 24, 2015 at 9:19 am
Ditto what Phil said.
We probably need a more complete understanding of what you are doing because the expected types should not be changing at runtime if you defined...
February 24, 2015 at 9:13 am
Sangeeth878787 (2/23/2015)
I am glad for your reply, I would happily to share the scope the project but at the moment the company haven't explained to me itself, all I...
February 24, 2015 at 8:09 am
Viewing 15 posts - 76 through 90 (of 600 total)