计算并返回2个字段匹配的位置

时间:2015-05-12 13:02:09

标签: sql teradata

我试图编写一个基于2个字段匹配来计算结果的脚本 - 但是不能完全匹配,但是值会在整个表中重新出现。

例如,我想找到字段A和字段B = x& y,分别(并计算那些结果)但是,字段A不总是X而字段B不总是Y.而且,字段A和字段B值是未知的。这是我到目前为止所写的内容:

select a.fielda, b.fieldb, count (*)
from tableA a
join tableB b
on a.fieldd = b.fieldd

where a.fielda = b.fieldb --I know this is a problem, just for notes on what I'm trying to accomplish.
group by b.fieldb, a.fielda
order by b.fieldb.

我是新手,所以任何帮助都将不胜感激。提前谢谢。

2 个答案:

答案 0 :(得分:0)

function LoadMRIGUI
clc
clear all

handles.figure1  = figure('Position',[100 100 400 400],'Units','normalized');

P_axes = axes('Units','normalized','Position',[.2 .2 .6 .6]);

handles.ButtonStart= uicontrol('Style','push','String','Start','Position',[40 350 50 30],'Callback',@(s,e) btnStart_callback);
handles.ButtonStop= uicontrol('Style','push','String','Next','Position',[100 350 50 30],'Callback',@(s,e) btnNext_callback);

    %// === NEW === \\%
%// text box to see current index

handles.IdxTitle = uicontrol('Style','text','String','Index','Position',[160 350 50 20]);
handles.Idxbox = uicontrol('Style','text','String','1','Position',[220 350 50 20]);

    function btnStart_callback

        %// === NEW === \\%
        S = load('mri');
        d = S.D(:,:,1);

        handles.Img = imshow(d,'Parent' , P_axes);
        setappdata(handles.figure1 , 'Indx' , 1)
        setappdata(handles.figure1 , 'Data' , S.D)
    end


    function btnNext_callback
        indx = getappdata(handles.figure1 , 'Indx');
        D= getappdata(handles.figure1 , 'Data');
        d = D(:,:,indx+1);
        set(handles.Img , 'CData',d);
        setappdata(handles.figure1 , 'Indx' , indx+1);

        set(handles.Idxbox,'String',num2str(indx+1));
    end

end

答案 1 :(得分:0)

托宾对我说得对。我不认为通过选择我已经找到记录的两个字段,这两个字段一起存在...我想是脑屁。谢谢你的帮助!