Saturday 15 May 2010

sql - Select unique data based on Single Column from Join Query -



sql - Select unique data based on Single Column from Join Query -

query

select distinct device.name device, devicepool.name devicepool, device.description phone_description, numplan.dnorpattern primary_did, applicationuser.name applicationuser left outer bring together applicationuserdevicemap on applicationuserdevicemap.fkapplicationuser = applicationuser.pkid left outer bring together device on device.pkid =applicationuserdevicemap.fkdevice left outer bring together devicenumplanmap on devicenumplanmap.fkdevice=device.pkid total bring together numplan on numplan.pkid = devicenumplanmap.fknumplan , numplan.dnorpattern not '%#%' left outer bring together devicepool on device.fkdevicepool = devicepool.pkid (devicenumplanmap.numplanindex=1 or devicenumplanmap.numplanindex null) , device.name 'sep%' , device.description not '%ipcom%' , applicationuser.name='actuser' order devicepool.name, numplan.dnorpattern

which results in

device | devicepool| phone_description | primary_did | name -------------------------------------------------------------------------- sepa40cc3956a58 | dbl_test | auto 8964 | 8964 | actuser sep00230432abdc | dp_w00301 | auto 8968 | 4082600 | actuser sep001bd5e86761 | dp_w00301 | sep001b54520367 | 7001 | actuser sep00260b5e1997 | dp_w00301 | auto 8965 | 8965 | actuser sep00175a756654 | dp_w06851 | dobson,ronda | | actuser sep00175a756654 | dp_w06851 | dobson,ronda | 8505998965 | actuser sep001b54520367 | dp_wa6201 | sep001b54520367 | | actuser

i need results primaru did null or blank. has caused non-unique entry in device column sep00175a756654 repetaig twice.

so ideally result should be,

device | devicepool| phone_description | primary_did | name -------------------------------------------------------------------------- sepa40cc3956a58 | dbl_test | auto 8964 | 8964 | actuser sep00230432abdc | dp_w00301 | auto 8968 | 4082600 | actuser sep001bd5e86761 | dp_w00301 | sep001b54520367 | 7001 | actuser sep00260b5e1997 | dp_w00301 | auto 8965 | 8965 | actuser sep00175a756654 | dp_w06851 | dobson,ronda | 8505998965 | actuser sep001b54520367 | dp_wa6201 | sep001b54520367 | | actuser

i need solution on how utilize inner bring together here. if reason can explained.

sql cucm

No comments:

Post a Comment