Viewing 15 posts - 706 through 720 (of 1,923 total)
Adding a Row_Number partitioned by the Year(SubmitDate) order by SubmitDate in the CTE and in the final select selecting values <= 5 on Row Number will get you there.....
August 24, 2011 at 11:13 am
Hmmm.. interesting to see this... i tried simulating the question by using 3 variations , cte, cross apply ( from nils gustav ) and OP's method.
Here is test code:
select...
August 23, 2011 at 11:18 am
The query you posted did not have a join statement, but the error message says differently. Is the procedure complete? or you just posted part of the SP?
August 22, 2011 at 9:51 am
indraneelandhavarapu-866099 (8/22/2011)
Hey thx for your instant response. I have to check this solutions on my DB now.
You're welcome. Drop by here if you don't understand the code and the explanation....
August 22, 2011 at 1:51 am
Your answer to the interviewer is not wrong, you can use any looping mechanism ( cursor or while loop ) for this. But there are 2 more mechanisms of deriving...
August 22, 2011 at 1:41 am
See if this expalantion helps.
All the explanation are in the comments.
Declare @month varchar(10) = 'NOvember' ,
@date int = 24
--==...
August 19, 2011 at 9:11 am
I went on and ran the tests , one at a time, around 50 times. Now i see a difference. Both tests are yeilding more or less the same metrics....
August 18, 2011 at 10:59 am
Gail, i ran the tests for around 25 times.. i still see that behavior.. any weird bug in the system?
August 18, 2011 at 10:51 am
SQLRNNR (8/17/2011)
August 17, 2011 at 8:51 pm
If you do not have any records in child table, then you wont get any rows in resultset. Can you specify your requiremtn exactly? some sample data and expected result...
August 14, 2011 at 11:33 am
Oracle_91 (8/3/2011)
There is a slight difference 🙂
using my implementation if i execute
exec usp_p1 'b1',null,null,null
-- output which is expected.
/*
b1p12001-01-01 00:00:00.0002002-01-01 00:00:00.000
*/
using ur implementation
exec usp_p1 'b1',null,null,null
-- no output. which is...
August 3, 2011 at 9:52 pm
How about this?
create proc usp_p2
@branchcode varchar(10),
@promocode varchar(10)
as
begin
select * from sample
where (1=1)
and branchcode = ISNULL(@branchcode , branchcode )
and promocode = ISNULL ( @promocode , promocode )
end
Seemed straight forward to me...
August 3, 2011 at 9:36 pm
Try this:
SELECT DISTINCT c1.id ReferralID
,a1.id UAID
,c7.c_te QuestionInForm
...
August 2, 2011 at 9:46 am
What will happen if there are 2 differnct RcTypes other than 0 ?
July 14, 2011 at 12:15 pm
How about this then?
; with TableCTE AS
(
SELECT *
FROM
...
July 8, 2011 at 10:49 am
Viewing 15 posts - 706 through 720 (of 1,923 total)