Left Outer Join Problem | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Left Outer Join Problem

I have the following table<br /><br />log( occuredTime datetime, term varchar(50), termImportance float); <br /><br />Now, every 5 minutes, arbitary terms with particular importance will be stored in it.<br /><br /><br />The query i wanted now is :<br /><br /><br /> For a particular term, between time t1 and time 2 what are its importance values.<br /><br /> Note: time points at which term doesn’t appear should also be present, may be with its importance set to zero or null.<br /><br />Any Ideas!!<br /><br />Novice Coder here!!!<br />[<img src=’/community/emoticons/emotion-6.gif’ alt=’:(‘ />]
Post some sample data and the result you want Madhivanan Failing to plan is Planning to fail
yes, we need the query to give an answer —————————————-
http://dineshasanka.blogspot.com/

You can use a CASE WHEN construct to evaluate a column and return the one or the other value: SELECT occurredTime, term, CASE WHEN occurredTime BETWEEN @t1 AND @t2 THEN termImportance ELSE null END
FROM log BTW, this doesn’t have anything to do with a LEFT JOIN.
hi folks, thanks for your help! I figured out what i am actually looking for! BTW, I think i haven’t explained the question properly! Here is my question cum answer: select occuredTime, sum( Case term when @term then termImportance else 0 end) from log where occuredTime >= @startTime and occuredTime <[email protected] group by occuredTime order by occuredTime;
Special thanks to Adriaan for introducing case expression to me!
]]>