Search code examples
adobedistinctcampaign-monitor

Adobe Campaign: How to SELECT DISTINCT on queryDef?


We are selecting values from two columns which does not include primary key or unique & binding it to drop down and thus getting multiple values in dropdown.

The code snippet is:

    ctx.students = xtk.queryDef.create(  
  <queryDef schema="stf:student" operation="select">  
    <select>  
      <node expr="@firstname"/>  
      <node expr="@lastname"/>  
    </select>  
    <orderBy>  
      <node expr="@firstname" sortDesc="false"/>  
    </orderBy>  
  </queryDef>).ExecuteQuery();

How can we can fetch only DISTINCT records?

Thanks Sachin


Solution

  • Use distinct="true"

        ctx.students = xtk.queryDef.create(  
      <queryDef schema="stf:student" distinct="true" operation="select">  
        <select>  
          <node expr="@firstname"/>  
          <node expr="@lastname"/>  
        </select>  
        <orderBy>  
          <node expr="@firstname" sortDesc="false"/>  
        </orderBy>  
      </queryDef>).ExecuteQuery();