SQL query to retrieve the same record because no. boxes

Hi all

I have a table of Bill XXINV.

the columns are

INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES

1122                XXITEM1                    1                    5

1123                XXITEM2                     2                   6

I can do a sql query so that I can retrieve the same records repeated as number INVH_BOXES.

Select * from XXINV

where invh_no = 1122

output:

INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES

1122                XXITEM1                    1                    5

Desired output:

INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES

1122                XXITEM1                    1                    5

1122                XXITEM1                    1                    5

1122                XXITEM1                    1                    5

1122                XXITEM1                    1                    5

1122                XXITEM1                    1                    5

or

INVH_NO INVH_ITEM_CODE INVH_QTY INVH_BOXES

1122 XXITEM1 1 1 of 5

1122 XXITEM1 1 2 of 5

1122 1 3 5 XXITEM1

1122 XXITEM1 1 4 of 5

1122 XXITEM1 1 5 of 5

Please suggest. Like I need to print each line in a single page to stick them on boxes so that packaging.

Kind regards

Afzal.

Just add INVH_ITEM_CODE to the connection by the clause.

Select invh_no

invh_item_code

invh_qty

to_char (, 'fm99') | 'from ' | TO_CHAR (invh_boxes, 'fm99') invh_boxes

of xxinv

where invh_no = 1122

connect

by level<=>

and prior invh_item_code = invh_item_code

and prior sys_guid() is not null

Tags: Database

Similar Questions

  • SQL query to retrieve a single record for each employee of the following table?

    Hi all

    Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.

    CREATE TABLE xxc_contact)

    empnum NUMBER,

    alternatecontact VARCHAR2 (100),

    relationship VARCHAR2 (10),

    phtype VARCHAR2 (10),

    Phone NUMBER

    );

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)

    expected result:

    EmpNum AlternateContact Relationship PhType Phone       

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Thanks in advance.

    994122 wrote:

    Thank you all, that I got a result

    http://www.orafaq.com/Forum/m/620305/#msg_620305

    By Lalit Kumar B...

    Specifically, the two simple solutions provided were:

    1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).

    SQL > column alternatecontact format A20;

    SQL >

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))

    3 FROM xxc_contact one)

    4. WHEN r = 1

    /

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)

    3 WHERE phone = rn

    4.

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Kind regards

    Lalit

  • SQL query to get the NULL records after the last matching flag

    I have a xx1 table with id and flag columns. So I want the data in this table, after the last flag matched. I want that data to id 7 in the rooms. Even if the id 2,3,5 are null flag 'Y' was at 6. ID so I need a query to get the data of the xx1 table after the last correspondence flag (from 7 to 9 id).

    SQL > create table xx1

    2 (identification number,

    3 flag varchar2 (10));

    Table created.

    SQL > insert into xx1 values (1, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (2, null);

    1 line of creation.

    SQL > insert into values xx1 (3, null);

    1 line of creation.

    SQL > insert into xx1 values (4, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (5, null);

    1 line of creation.

    SQL > insert into xx1 values (6, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (7, null);

    1 line of creation.

    SQL > insert into values xx1 (8, null);

    1 line of creation.

    SQL > insert into values xx1 (9, null);

    1 line of creation.

    SQL > select * from xx1.

    FLAG OF THE ID

    ---------- ----------

    1. IS

    2

    3

    4. IS

    5

    6. IS

    7

    8

    9

    9 selected lines.

    SQL >

    Hello

    user11164339 wrote:

    Hi Frank - when I run the query, I don't see the results data.

    I get

    FLAG OF THE ID

    ----- ----------

    7

    8

    9

    What you do differently?

  • SQL query to represent the data in the graph bar

    Hello

    JDev 11.1.1.5.0

    We must create a dashboard to track the translation. We have created the ADF table with buttons 'Create', 'Update' and 'Delete' to manipulate the table.

    Our DB table structure is

    File_id (PK), File_Name, ToSpanish - ARE (YES/NO), beginning of the ToSpanish, ToChina(YES/No), ToChina-Date... etc.

    Once the translated file required language then user must update the DB table using the button "Update".

    So far, we have implemented the requirement above.

    We need represent the status of the translation in the graph bar with the language as X access and file count get access Ex: Spanish-100 China - 200 files files

    Please suggest the sql query to retrieve the necessary info from the DB table that can be represented in the graph bar. Also, it would be great, if you can provide a pointers to create a bar chart.

    Thanks in advance,

    MSR.

    If you set your major increment and minor than 1, then you won't not show decimal points.  You can try setting these 10 or 100 to reach your goal.

    Subtype = "BAR_VERT_CLUST" >

                 

  • SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate

    Hello

    SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate.

    Please help on this script and let me know if you need more details.

    ---

    You use a SELECT statement.  Let me know if you need more details.

  • Insert the same record (same key) in different sessions

    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
    PL/SQL Release 10.2.0.5.0 - Production
    CORE Production 10.2.0.5.0
    AMT for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production

    Hello! I am inserting the same record in 2 different sessions without validation using TOAD:
    insert into FIFAPPS.TESTES values(3);
    in this table, where ID is a key:
    CREATE TABLE FIFAPPS.TESTES
    (
      ID  NUMBER
    )
    In the first session, it goes well, but for the next session... It of just execution and never ends. My question is what happens when I insert the second session? TX in advance.

    You have a unique index or primary key (which will automatically index) on the column?

    Oneself up to the entrance in the first insert your index? Since you insert same value in another session, he waits for the lock on index to be released. If the first session agrees, you will get an error (duplicate). If the first session, second session restorations go...

  • How do I install sql 2008 and sql 2008 R2 on the same user account in vista

    I am trying to install sql 2008 and sql 2008 r2 on the same user account and get error message that the account cannot be used. How can I install sql 2008 and sql 2008 r2 on the same user account in vista

    Hello

    try to repost/ask in the SQL Server forums

    http://social.msdn.Microsoft.com/forums/en/category/SQLServer/

  • FDMEE 11.1.2.4 - how to load the same record source of 2 different custom in HFM members

    Hi Experts,

    We have the following situation:

    We need download a source document unique member 2 custom end balance as well as two rollforward Member custom movement 2 (additions, for example), the SAME account.

    In our GL, we have separate accounts for the additions, disposals, depreciation, etc.   In HFM, we use custom for these last members.

    I tried the multi-dimensions mappoing member card custom 2 individual based on the story.   It works fine, but when I add another condition by using the same account of source and card balance end Member, he only ended up filling a 2 custom members (according to what has been covered last importing).

    What would be the best way to load a single 2 custom members (same account) source document?

    I wanted to use the accounts of logic since I know that would work, but our financial team do not accept this approach.

    It is even possible to load the same record of 2 different HFM Member?  Even if we loaded the file even a second time in another place, I think that it still would replace what took the first time, instead of loading again to another custom on the same member account.  Even if we loaded to HFM on 'merge '?

    Any ideas at all would be appreciated.

    Thank you
    Mark Smith

    Why your financial team will not accept the approach of the accounts of the logic? He is the obvious solution to your problem. FDM or FDMEE, you can only load on the data at the intersection of a target element. If you want to load the same piece of data at several intersections in the target, then you need to have this piece of data repeated in data sources n then you will need something in the source that could identify how unique each copy so you can map correctly. As noted it is one of the main functions of the accounts of the logic, other approaches are likely to be messy, more prone to error and much harder to verify.

  • SQL query to display the sum of the values of each June and December

    Hello having problems of construction of a query to the list SQL query to display the sum of the values of each June and December each year.

    My Table;

    TABLE name: MONTH_TERM

    Fields with values:

    TERM_KEYMONTH_ACTUALMONTH_DATE
    8250001/11/2015 0:00
    8245001/12/2015 0:00
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:00
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:00
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    What I would like to see in a query result:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/2015 0:00
    8245001/12/2015 0:00950
    8240501/01/2016 0:00
    8240001/02/2016 0:00
    8245001/03/2016 0:00
    8242501/04/2016 0:00
    8243501/05/2016 0:00
    8241006/01/2016 0:002525
    8240901/07/2016 0:00
    8241501/08/2016 0:00
    8242009/01/2016 0:00
    8242210/01/2016 0:00
    8243611/01/2016 0:00
    8255601/12/2016 0:002658
    8256801/01/2017 0:00
    8262402/01/2017 0:00

    ---

    Here's my query:

    Select

    "TERM_KEY,"

    "MONTH_ACTUAL,"

    to_char(MONTH_DATE,'MM/YYYY') MONTH_DATE,

    DEAL to_char (MONTH_DATE, 'MM')

    WHEN '06' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 1 and 6

    AND term_key = 82)

    WHEN '12' THEN (SELECT SUM (MONTH_ACTUAL)

    OF MONTH_TERM

    WHERE the to_char (MONTH_DATE, 'MM') between 7 and 12

    AND term_key = 82)

    ELSE null

    END as SIX_MO_CUMM,

    of MONTH_TERM

    where term_key = 82

    It's my results:

    TERM_KEYMONTH_ACTUALMONTH_DATETotal of 6 months
    8250001/11/15 0:00
    8245001/12/15 0:003608
    8240501/01/16 0:00
    8240001/02/16 0:00
    8245001/03/16 0:00
    8242501/04/16 0:00
    8243501/05/16 0:00
    8241001/06/16 0:003717
    8240901/07/16 0:00
    8241501/08/16 0:00
    8242001/09/16 0:00
    8242210/01/16 0:00
    8243601/11/16 0:00
    8255601/12/16 0:003608
    8256801/01/17 0:00
    8262401/02/17 0:00

    Any ideas on how to fix would be great

    Select term_key,

    month_actual,

    month_date,

    case mod (to_char (month_date, 'mm'), 6)

    When 0 then sum (month_actual)

    During)

    term_key partition

    order of month_date

    between the previous month '5' interval and the current line

    )

    end '6 MONTHS in TOTAL'

    from tbl

    order of term_key,

    month_date

    /

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 500 NOVEMBER 1ST, 15TH
    82 450 1 DECEMBER 15 950
    82 405 1 JANUARY 16
    82 400 1 FEBRUARY 16
    82 450 1ST MARCH 16
    82 425 1ST APRIL 16
    82 435 1 MAY 16
    82 410 2525 1 JUNE 16
    82 409 1 JULY 16
    82 415 1ST AUGUST 16
    82 420 16 - SEP - 01

    TERM_KEY MONTH_ACTUAL MONTH_DAT 6 MONTHS TOTAL
    ---------- ------------ --------- --------------
    82 422 1 OCTOBER 16
    82-436 NOVEMBER 1, 16
    82 556 2658 1 DECEMBER 16
    82 568 1 JANUARY 17
    82 624 1 FEBRUARY 17

    16 selected lines.

    SQL >

    SY.

  • How to return values from the record following instead of in the same record in LOV

    Hi all

    I use Forms 10 G.

    I have a block of details. In what in the 3rd column, I have a LOV.

    My requirement is let say I asked for it from the 1st and 2nd column, and it shows 1 record.

    After that if I pressed F9, then it should display the LOV list and, when I select a value any then it will create a new record with the same value of 1st and 2nd column.

    Example: -.

    Agenda provider country
    123ABCIndia

    We here in the column 'Country' LOV. Then when I pressed F9 then Lov should be displayed.

    as below.

    List of countries
    India
    U.S..
    Japan

    It works very well so far.

    Now if I select from the USA in the list then it should create a new record with the values of 1st and 2nd column.

    Agenda provider country
    123ABCIndia
    123ABCJapan

    How can I do this?

    Besically I need, rather than return the value in the same record, he must return to the next with the exsiting values record.

    The algorithm is:

    -use the KEY-LISTVAL about to 'COUNTRIES '.

    -LOV execution using builtin show_lov

    -store the return value Lov any parameter or a local variable in your trigger code ( vL_dummy_Deger varchar2 (100); )

    -Create registration

    -assign value to any new item you want to

    code like this:

    declare

    vLDummy boolean;

    vL_dummy_Deger varchar2 (100);

    Start

    -lov runs lov ruturns value is assigned to all the dummy elements to store Lov, return value. (no need to display)

    "-" DUMMY "point lets store lov, return value.

    vLDummy: = show_lov ('LOV_ULKE');

    --

    vL_dummy_Deger: =: model;

    create_record;

    : new_item: = vL_dummy_Deger;

    end;

  • Query to retrieve the level 2 supervisors

    Hi all

    I use the following query to retrieve the people which is under the supervision of a given person_id... Is it possible to modify this query (see below) in order to get two levels of employees? something like:

    Supervisor 1
    Employee 1
    Employee 2
    Employee 3
    Supervisor 2
    Employee 4
    Employee 5
    Employee 6

    The query works if I pass the person_id 1 for example supervisor that I would get used 1 2 and 3. But if I pass an id of the person who, of higher hierarchy, I will just get supervisor 1 supervisor 2... And I need all the people (just two levels down)

    Select distinct *)
    Select distinct ppf.first_name |' '|| PPF.last_name
    ppf.last_name
    fu.user_name
    fu.user_id
    ppf.person_id
    papf.person_id Manager
    pi.image_id
    initcap (hla.description) LOCATION
    pb.NAME pay_basis_name
    pax.grade_id
    haou.name
    employment_category
    ppos.date_start
    of per_assignments_x pax
    per_grade_definitions pgd
    per_people_x WP
    fnd_user fu
    per_all_people_f women's wear
    per_images pi
    hr_locations_all hla
    per_pay_bases pb
    hr_all_organization_units haou
    per_periods_of_service OPP
    where ppf.person_id = pax.person_id
    and trunc (sysdate) between papf.effective_start_date and papf.effective_end_date
    and fu.person_party_id = papf.party_id
    and pax.supervisor_id = papf.person_id
    and pi.parent_id (+) = ppf.person_id
    and pi.table_name (+) = "PER_PEOPLE_F".
    and pax.person_id = ppf.person_id
    and hla.location_id (+) = pax.location_id
    AND ppf.current_employee_flag = 'Y '.
    AND pb.pay_basis_id = pax.pay_basis_id
    AND haou.organization_id = pax.organization_id
    AND ppos.person_id = ppf.person_id
    AND pax.grade_id = pgd.grade_definition_id
    AND papf.person_id =: inPersonId
    UNION ALL
    Select ppf.first_name |' '|| PPF.last_name
    ppf.last_name
    fu.user_name
    fu.user_id
    ppf.person_id
    papf.person_id Manager
    pi.image_id
    initcap (hla.description) LOCATION
    pb.NAME pay_basis_name
    pax.grade_id
    haou.name
    employment_category
    ppos.date_start
    of per_people_x WP
    per_grade_definitions pgd
    fnd_user fu
    per_all_people_f women's wear
    HR_WORKING_PERSON_LISTS HWPL
    per_images pi
    per_assignments_x pax
    hr_locations_all hla
    per_pay_bases pb
    hr_all_organization_units haou
    per_periods_of_service OPP
    where
    trunc (sysdate) between papf.effective_start_date and papf.effective_end_date
    and fu.person_party_id = papf.party_id
    AND HWPL.owning_person_id = papf.person_id
    and hwpl.selected_person_id = ppf.person_id
    AND pi.parent_id (+) = ppf.person_id
    and ppf.current_employee_flag = 'Y '.
    and pax.person_id = ppf.person_id
    AND hla.location_id (+) = pax.location_id
    AND pb.pay_basis_id = pax.pay_basis_id
    AND haou.organization_id = pax.organization_id
    AND ppos.person_id = ppf.person_id
    AND pax.grade_id = pgd.grade_definition_id
    AND papf.person_id =: inPersonId
    ) order of last_name

    Hello Alejandro,

    You can play a little bit with one below with what you find most comfortable.

    / * multi level * /.
    Select the level
    assignment_number
    assignment_id
    Manager
    , (select full_name from per_people_x where person_id = pax.person_id)
    , sys_connect_by_path ((sélectionnez employee_number dans per_people_x où person_id = pax.person_id), '-->')
    of per_assignments_x pax
    where primary_flag = 'Y '.
    connect by prior person_id = Manager
    Start by person_id = 1523

    / * level 2 only * /.
    Select (select full_name from per_people_x where person_id = pax1.person_id)
    , (select full_name from per_people_x where person_id = pax2.person_id)
    of per_assignments_x pax1
    per_assignments_x pax2
    where pax1.supervisor_id = 1523
    and pax1.primary_flag = 'Y '.
    and pax1.person_id = pax2.supervisor_id
    and pax2.primary_flag = 'Y '.

  • Query to retrieve the latest version

    Hello
    I am trying to create a query that retrieves the latetst of a product version. There are 2 tables I have mark from, we have the product number and we got the version - a varchar2 data type (60). Are versions A, B, c... etc. So, I want to give me a line for each product with its latest version of the application. It's the query I have so far


    SELECT A0. Prod_num, A0.version
    FROM (SELECT A0B. Prod_num, A0.version
    Of tb_1 A0, tb_2 A0B
    WHERE (A0.tb_1pk = A0B.tb_2pk)) A0
    ranking by A0. Prod_num

    Returns duplicate versions and product lines.

    Thank you.

    Without seeing sample data...

    SELECT A0B. Prod_num,
    Max (a0.version)
    Of tb_1 A0, tb_2 A0B
    WHERE (A0.tb_1pk = A0B.tb_2pk)
    AO8.prod_num GROUP;

  • Query to retrieve the number of transactions in every 1 hour for the end

    Hello

    Could someone help to write a query to retrieve the number of transactions in every hour for the last month.

    Case:
    I / P

    If Timestamp1
    1 01/01/2008 00:00:01
    CAS2 01/01/2008 00:01:01
    case3 01/01/2008 01:00:01
    1 01/01/2008 01:02:01
    case4 01/01/2008 01:10:01
    Service5 01/02/2008 02:00:01
    Case6 01/02/2008 02:10:01
    case7 2008-02-01 23:00:01
    .............................

    .............................
    case... 2008-01-31 00:24:00


    O/P
    cases of to_time of time
    2008-01-01 00:00:00 01/01/2008 01:00 2
    2008-01-01 01:00:01 01/01/2008 02:00 3

    .........................
    .........................

    etc.

    Any help really appreciated

    We can do this by using analytic functions

    Here's what I did:

    create table timestamp1 (date of ts)

    Select * from timestamp1
    2008-10-30 15:41:13
    2008-10-30 15:41:05
    2008-10-30 15:40:03
    2008-10-30 14:58:26
    2008-10-30 14:29:45
    2008-10-30 13:17:48
    2008-10-30 08:29:50
    2008-10-30 06:05:51
    2008-10-30 03:41:52
    2008-10-30 02:29:54

    Select distinct to_char (ts, 'hh24') frmhrs,
    TO_CHAR (ts, 'hh24') + 1 tohrs, count (ts) OVER (order by to_number (to_char (ts, 'hh24')) RANK BEFORE (1/24))
    of timestamp1
    When trunc (ts) = trunc (sysdate) - I added this just to make sure that I get for data of today
    order of frmhrs

    FRMHRS TOHRS CNT
    1-3-02
    03-4-1
    06 7 1
    1-9-08
    13 14 1
    14 15 2
    15 16 3

    You can customizeas by your need.

  • SQL Query to retrieve records in a table with the same records or only one record in a table

    Hello

    Got a curious requirment to extract the Non-distincts records in a table

    Example of

    Account number Type of account
    12345SB
    12345

    SB

    12346CR
    12346SB
    12347SB
    12348CR
    12349SB

    Requrirement is to retrieve the records as follows

    Result must be

    Account number Type of account
    12345SB
    12345

    SB

    12347SB
    12348CR
    12349SB

    You will notice that 12346 which has two separate lines have been eliminated in the result. I tried several qeries to achieve this result, one or the other had a few mismatch. Can someone give me a request for it.

    Thanks in advance.

    SELECT ACCOUNT_NUMBER,

    ACCOUNT_TYPE

    DE)

    SELECT ACCOUNT_NUMBER,

    ACCOUNT_TYPE,

    COUNT (*) ON CNT_ACC (ACCOUNT_NUMBER PARTITION).

    COUNT (*) ON CNT_NUM_TYP (PARTITION ACCOUNT_NUMBER, ACCOUNT_TYPE)

    FROM T1)

    WHERE CNT_ACC = CNT_NUM_TYP;

    exit;

    12345 SB
    12345 SB
    12347 SB
    12348 CR
    12349 SB
  • SQL Query to retrieve records for all after the Max Dates.

    Hello everyone,

    I am trying to retrieve the record more recent, based on the date field ( nextDate ).

    Currently, there are only 4 records in the MC_Maintenance table and two in the Machine table.

    Machine table

    MC_id             EquipID          

    1                      0227

    MC_id EquipID

    2                     0228

    ---------------------------------

    MC_Maintenance table

    Maint_id MC_id Next_maint

    1                      2                      08/25/2010     

    2                      2                      07/01/2010

    3                      1                      2010-11-06

    4                      1                      07/11/2010

    I have am trying to accomplish is,.

    the list of the two machines of the table of the Machine with the MAX (Next_maint) control the list of MC_Maintenance results

    These are the records I want to display.

    Maint_id MC_id Next_maint

    1                      2                      08/25/2010

    4                      1                      07/11/2010                 

    Here is the SQL query

    SELECT

           MC. MC_ID as ID,

    MC.complete_Date completed.

    MC.next_maint as nextDate,.

    MC.maint_notes as noted,.

    MC.facility Facility.

    M.EquipId,.

    $m.name as the name.

    M.SerialNumber SN.

    M.dept as dept.

    M.Freq as freq

    Of MC_Maintenance MC, Machine M

            where  MC. MC_ID = M.MC_ID

    '           Using MAX (nextDate)

    Any ideas would be useful.

    TJ

    I thought it was a simple group of problem?

    SELECT M.EquipID, MC.MC_ID, Max(MC.next_maint)
    FROM MC_Maintenance MC INNER JOIN Machine M ON MC.MC_ID = M.MC_ID
    GROUP BY M.EquipID, MC.MC_ID
    

Maybe you are looking for