sql server 2008 - SQL Join Statement based on date range -


new sql dev here. i'm writing call log application our asterisk server. in 1 table (cdrlogs), have call logs phone system (src, dst, calldate, duration). in table have (employees) have empname, empext, extstartdate extenddate). want join 2 on src , empext based on using particular ext on date of call. 1 user per extension in given time frame.

for example, have had 3 different users sitting @ x100 during month of july. in employees table, have recorded dates each of these people started , ended use of ext. how join reflect that?

thanks in advance

perhaps like:

select a.*, b.* cdrlogs inner join employees b   on a.src = b.empext   , a.calldate between b.extstartdate , coalesce(b.extenddate,getdate()) 

please replace * relevant fields needed , there may better way join on between seems possibly cause overhead, can't think of better way presently.


Comments

Popular posts from this blog

codeigniter - Fatal error: Call to undefined function lang() in CI Merchant using CardSave -

python - Received unregistered task using Celery with Django -

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -