How define query to filter

When i write Query = select e.cui.id from ezinfo$Referencias e
where e.cui.id in
(select d.cui from ezinfo$Dpi d)

or Query = select e.cui.id from ezinfo$Referencias e, ezinfo$Dpi d
where e.cui.id = d.cui.id

Does not work, how I define this under Query to use Table, GroupTable or whatever kind of tables ?

By default the Query = select e from ezinfo$Dpi e
and show data but I need show data about the attribute cui.id

Dear friend i resolve:

    @Inject 
    private GroupDatasource<Referencias, UUID> referenciasesDs; 
    public void applyFilterReferencias(){ 
        try { 
            //referenciasesDs.setQuery("select r from ezinfo$Referencias r where r.cui.id =:" + dpiDs.getItem().getValue("id").toString()); 
            referenciasesDs.setQuery("select r from ezinfo$Referencias r where r.cui.id =:ds$dpiDs.id"); 
            referenciasesDs.refresh(); 
        }catch (Exception ex){ 
            ex.printStackTrace(); 
        } 
    }