MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » October 2006

Re: Insert First Row



fixed

Of course the problem is that the XMSMN1 field isn't distint. You'll have to use MIN or SUM on it.

INSERT INTO NEWSYS/EMLCMP (EMLADDR, EMEMP#) SELECT XMMAIL, MIN(XMSmn1) FROM posmstp WHERE xmmail <> ' ' GROUP BY XMMAIL, XMSmn1


Michael Ryan wrote:
I thought I could do this, but it's not working for me. Here's my SQL
statement:

INSERT INTO NEWSYS/EMLCMP (EMLADDR, EMEMP#) SELECT DISTINCT XMMAIL,
XMSmn1 FROM posmstp WHERE xmmail <> ' '

I have records in posmstp like this:

XMMAIL     XMSMN1
A_Value      501
B_Value      123
A_Value      789
C_Value      555

I want the resultant table to be:

XMMAIL     XMSMN1
A_Value      501
B_Value      123
C_Value      555

In other words, I just want the values from the first XMMAIL record I
encounter. I though the DISTINCT would do that. What do I need to do?

TIA






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact