× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Select distinct color from blah/blah




Kevin Bucknum
Senior Programmer Analyst
MEDDATA/MEDTRON
Tel: 985-893-2550

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
Booth Martin
Sent: Friday, August 18, 2017 1:33 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: SQL group want only one of each group

Thanks.

Using your example, I want to loop through the file and create a
subfile of
just the colors. If there are 300 records but only 7 colors, I want a
subfile of 7
rows.



On 8/18/2017 3:26 AM, Paul Bailey wrote:
What do you want from the query? What does your query look like?

For example, to get the count of rows with the same colour:

select colour, count(*) from theFile group by colour; (replace
colour
with size or style as required)

Because each colour, style and size has a unique stock number, if
you
want a list of stock numbers then a group by will just give you
every
row because every row will be unique.


-Paul.


On 18 August 2017 at 07:21, Booth Martin <booth@xxxxxxxxxxxx> wrote:

Scenario: I have a product with 5 colors, 6 styles, and 7 sizes.
Every color has some of every style and every size. Every style
has
some of every color and every size. every size has some of every
color and every style. Each permutation has a unique Stock number.

I want 3 lists: group by color( 5 rows), group by style(6 rows),
group by
size(7 rows).

I can get the reports, correctly grouped, but I get as many rows as
there are records in the file. I can not figure out how to get
just
the first of each group.



--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email:
RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list
options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
a
moment to review the archives at
http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our
affiliate
link: http://amzn.to/2dEadiD


--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To
subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.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 on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.