• asm1212 (8/6/2012)


    Unfortunately, I am on a time constraint and dont have time to go through all that so I apologize and will just try to keep working with what i have and see if i can come up with what I am needing...

    No offense but seriously??? You don't have time to put together enough details to ask your question. Putting together the following sample data took me approximately 2 minutes.

    create table MyInvoice

    (

    InvoiceID int,

    DueDate date,

    GroupID int,

    SubscriberID int

    )

    insert MyInvoice

    select 101, '1/31/2012', 4, 22222 union all

    select 102, '1/31/2012', 4, 22222 union all

    select 103, '1/15/2012', 5, 33333

    select * from MyInvoice

    You did a fine job explaining that you want a view and what it should look like. Using the MAX function as suggested produces exactly the results you stated from your sample data.

    create view MyInvoiceViewWithMax

    as

    select MAX(InvoiceID) as InvoiceID, DueDate, GroupID, SubscriberID

    from MyInvoice

    group by DueDate, GroupID, SubscriberID

    go

    select * from MyInvoiceViewWithMax

    Total time working on the total solution (about 5 minutes including posting the code).

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/