July 14, 2010 at 8:57 am
ssis learner__ (7/14/2010)
... I dont really trust left joins ...
:w00t:
Me too! I hate them! They are commie bustards!
Vote conservatives! :-D:-D:-D
You wanted to say: "I don't really understand how left joins work".
Which most likely means you don't understand how any JOINs work.
You better to learn them, otherwise you will always struggle coding in T-SQL. There are a lot of sources of information which can help you, try this one for example:
July 14, 2010 at 11:32 am
No left join is needed for this so I wouldn't use one either.
;WITH cteTemp
AS
(
select [EMP],
[order_no],
EmpAccts = DENSE_RANK() OVER (PARTITION BY [EMP] ORDER BY [order_no]),
EmpRes = ROW_NUMBER() OVER (PARTITION BY [order_no] ORDER BY [counter] DESC)
from [dbo].[abcd]
)
SELECT [EMP],
MAX(EmpAccts) as No_of_accounts,
ISNULL(SUM(CASE WHEN EmpRes = 1 THEN 1 END),0) as resolutioncount
FROM cteTemp
GROUP BY [EMP]
July 14, 2010 at 11:43 am
bteraberry (7/14/2010)
No left join is needed for this so I wouldn't use one either....
One thing is when LEFT JOIN is not needed. Not trusting to LEFT JOIN (due to political or class affiliation :-D) is absolutely other thing (from diffferent opera) ...
Do you trust to INNER JOIN more than to LEFT JOIN?
What about RIGHT JOIN?
Are FULL and CROSS JOINS "political prostitutes", so you don't trust them either?
Do you trust in BIGINT but not in INT due to class-war thing?
Do you hate liars and therefore never set BOOLEAN variables to FALSE - always keep them as TRUE?
:w00t::w00t::w00t:
:-D:-D:-D
July 14, 2010 at 11:52 am
@Bt...........
OMG ..........!!!!!!!!!!!!!!
This is an unbelievable code man..... You must be a GGGenius........
Thank you so much for the help. ...
I just ran this code and got the exact results....
now let me research about the code and the function you used in it...DENSE_RANK() ,as I have never used this before.........
Thanks again...
Thanks [/font]
July 14, 2010 at 12:21 pm
@Eugene Elutin,
IGNORED..........................
Thanks [/font]
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply