Group wise maximum query

hi,
I have a table with following values
AUTOID
RNO
NAME
1
1
ACCOUNTS
2
1
IT
3
1
SALES
4
2
MARKETING
5
2
SALES
6
2
IT
7
3
MAINTANANCE
8
3
SUPPORT
9
3
ACCOUNTS
i need to get the max row of each RNo.
AUTOID
RNO
NAME
3
1
SALES
6
2
IT
9
3
ACCOUNTS
Regards,
Raghu
raghu

Also, you can try this one:
DECLARE @Table TABLE
AUTOID INT PRIMARY KEY ,
RNO INT ,
NAME NVARCHAR(50)
INSERT @Table
( AUTOID, RNO, NAME )
VALUES ( 1, 1, 'ACCOUNTS' ),
( 2, 1, 'IT' ),
( 3, 1, 'SALES' ),
( 4, 2, 'MARKETING' ),
( 5, 2, 'SALES' ),
( 6, 2, 'IT' ),
( 7, 3, 'MAINTANANCE' ),
( 8, 3, 'SUPPORT' ),
( 9, 3, 'ACCOUNTS' ) ;
SELECT *
FROM @Table ;
SELECT *
FROM @Table AS s
WHERE AUTOID IN ( SELECT MAX(t.AUTOID) AS mx
FROM @Table AS t
GROUP BY t.RNO ) ;
sqldevelop.wordpress.com

Similar Messages

  • Customer Group wise sales

    hi
    is there any standard report to check customer  group wise sales.
    Rajendra

    Hi Rajedra Prasad,
    Please find below the Some of the Standard Reports in SD:
    Sales summary - VC/2
    Display Customer Hierarchy - VDH2
    Display Condition record report - V/I6
    Pricing Report - V/LD
    Create Net Price List - V_NL
    List customer material info - VD59
    List of sales order - VA05
    List of Billing documents - VF05
    Inquiries list - VA15
    Quotation List - VA25
    Incomplete Sales orders - V.02
    Backorders - V.15
    Outbound Delivery Monitor - VL06o
    Incomplete delivery - V_UC
    Customer Returns-Analysis - MC+A
    Customer Analysis- Sales - MC+E
    Customer Analysis- Cr. Memo - MC+I
    Deliveries-Due list - VL04
    Billing due list - VF04
    Incomplete Billing documents - MCV9
    Customer Analysis-Basic List - MCTA
    Material Analysis(SIS) - MCTC
    Sales org analysis - MCTE
    Sales org analysis-Invoiced sales - MC+2
    Material Analysis-Incoming orders - MC(E
    General- List of Outbound deliveries - VL06f
    Material Returns-Analysis - MC+M
    Material Analysis- Invoiced Sales - MC+Q
    Variant configuration Analysis - MC(B
    Sales org analysis-Incoming orders - MC(I
    Sales org analysis-Returns - MC+Y
    Sales office Analysis- Invoiced Sales - MC-E
    Sales office Analysis- Returns - MC-A
    Shipping point Analysis - MC(U
    Shipping point Analysis-Returns - MC-O
    Blocked orders - V.14
    Order Within time period - SD01
    Duplicate Sales orders in period - SDD1
    Display Delivery Changes - VL22
    Shipment List Planning - VT11
    List of Incomplete Shipments -Try VT04/VT11/VT32
    Delivery without Shipments -Use VL06O
    List of Rebate Agreements   - VB(8
    If not, if it is a small report using ABAP Query you can develop New Report as per your requirment or Using SIS you can Develop you own report.
    Please Reward If Really Helpful,
    Thanks and Regards,
    Sateesh.Kandula

  • Warehouse report in Item group wise

    Dear Experts,
    In Warehouse report i need the breakup in item group wise.
    Now Warehouse report show all item's and item's details. But now i need all group along with that group item details.
    Ex:
    Group 1
    Item A - 50
    Item B - 70
    Item C - 120
    Item N - 100
    Group 2
    Item AA - 50
    Item BB - 70
    Item CC - 120
    Item NN - 100
    Group 2
    Item AA - 50
    Item BB - 70
    Item CC - 120
    Item NN - 100
    How to get this report. any solution
    Thanks and Regards,
    Chandru

    Try the following query as you will not be able to manipulate or change the standard warehouse report to your requirements:
    SELECT T2.[ItmsGrpNam], T0.[WhsCode], MAX(T0.[ItemCode]) AS [ItemCode], MAX(T1.[ItemName]) AS [Item Name], SUM(T0.[OnHand]) AS [OnHand] FROM OITW T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod GROUP BY T2.[ItmsGrpNam], T0.[WhsCode] ORDER BY T2.[ItmsGrpNam], T0.[WhsCode]
    Kind regards
    Peter

  • How To make group wise total in Bex report

    Hi!!! Guru's
    i m doing reporting on SD module, so client wann see the summerised report
    on delivarys, senario is the one sale order having the multiple delivery, so the
    i have to show the total result for all deliverys agianst the purticular sales order
    in one row.i know we can do that at the excel level but hot to do it at the query
    design level.highly appreciate u r help on this.
    wil asign pts for sure,,,
    thanks in adv
    Mohan

    Hi!!! Trippel K
    thanks for reply...
    my Q's is how to make the group wise total means, i m going to genaret the
    report on delivery delays on cube 0SD_C04 (Delivery Service), in that the the date
    is comming from the 2LIS_12_VCITM delivery item data, the schedule line data
    from 2LIS_12_VCSCL, when i m getting according to date wise it showing all data from item level n schedule line, the senario is i have to use date from item level n
    all delivery from schedule line, so any inputs regarding this, plz let me, wil appecite
    u inputs
    thanks in adv
    Mohan

  • Account Group wise vendor aging report

    Dear Gurus,
    How can I see vedor account group wise ageing report in a company code?i.e Trade Vendors, Non Trade Vndors wise aging report
    Thanks in adv.
    N.M.B

    Dear Raghavender
    No need to create to variant and all.
    You just go to S_ALR_87012085 then go to dynamic selections. There we can give account group whatever we want.
    If u have any doubts reg. this pls ask me
    Bye
    Murali

  • Report for monthly sales(sales office wise,sales group wise,plant wise)

    Please send the Report for monthly sales(sales office wise,sales group wise,plant wise)  with T.CODE.,

    Hi
    As per my knowledge there is no Standard Report in SAP based on sales office, sales group. and plant.
    You may create your own report using MC18,MC21 and MC24.... Otherwise ask your ABAPer's help...
    Muthu

  • Grouping customers and view customer open items list - Group wise

    Hi.
    I have some requirement from my client.
    He says that he want to view customer open items list group wise.
    In FBL5N we can give the selection of multiple customers. But he wants to group the specific customers and then view the open items for this group.
    For example: Client has 10 customers and out of these customers he wants to select and group 5 customers. And then he want to view open items list for this group.
    Can anyone help me how to group these specific customers in the total customers list. Also request you to provide me the option to view open items for this group of customers.
    Regards,
    Padmavathi

    Hi Padmavathi,
    It is possible. use Worklist for Customers.
    Go to OB55 and define a Worklist for Customers, and mention the list of Customers that you want to see under that Worklist.
    After this, when you to to FBL5N, you will get an option to select Worklist to run the list of open items.. and it would show open items of all customers that you have defined in your worklist.
    Also note that you will have to go to FB00, tab Line Items, and tick Worklists available. This is at User Level, so only that user will be able to see the worklist in his FBL5N transaction code.
    Regards,
    SAPFICO
    Edited by: SAPFICO on Feb 10, 2011 11:43 AM

  • List of blocked invoices purchase group wise

    Hi experts
    Any standard reports available for blocked invoices purchase group wise ? Wht is the Tcode for that?

    Hi,
    Check the Table  RBKP_BLOCKED

  • Sales Report Material Group-wise

    I want to generate Sales Report Material Group-wise is there any standard report.
    regards,
    Rajesh

    Hi
    Use the T.code: MCBK, this report tells you about Total stock received, total stock issue for sales order against the material group.
    Reward if it helps
    Regards
    Prasanna R

  • Material Group-wise Sales Report

    I want to generate Sales Report Material Group-wise is there any standard report.
    regards,
    Rajesh

    Hi Vinod,
    MB52 is giving stock of Material on Hand, I want sales report.
    regards
    Rajesh

  • Customer group wise sales report

    can somebody give me a clue as to how to take customer group wise sales report
    thanks

    HI,
    it will not get the sales report with customer group wise in standard SAP.
    in standard you will get the data for the following selection :
    a. Sales Office wise : MC-E
    b. Sales Organization wise : MC+2
    c. Material(Article) wise : MC+Q
    tell me one thing, whether u need the report customer group wise or customer account group wise.
    Regards,
    somu.

  • Sales group wise credit report

    Hello Experts
    Right now,we are using S_ALR_87012178 report for the report on customer open item due analysis.
    However there are a few limitations here.
    Firstly, we need Customer # (KUNNR) to be displayed along with the customer name (NAME1). Presently, only customer name is displayed.Assuming, this can be solved to a certain extent by modifying the coding with the help of an Abaper, there is another limitation.
    *We need 'Sales Group' wise split up. This 'Sales Group' NOT from CMR,but from SO. [Since, for a single customer there may be cases of multiple 'sales groups']*
    Any help/Suggestion, will surely be appreciated.
    Good day....
    Rgds
    Sumanth.Gururaj
    Consultant- SAP SD

    hi,
    exactly my mate is right in this.
    you are requested not to change the STD coding part of SAP.
    please go for new report instead of old one.
    regards,
    balajia

  • Profit center group wise balance sheet and trading account report req

    Hi.
    We are using Profit ceter accounting for one of our clients.its ECC 6.0 therefore New GL is activated. FSV is not configured.
    Now I want to get the reports - Profit center group wise balance sheet and trading a/c.
    Can anyone help me in this regard.
    Thanks in advance.
    Regards,
    Padmavathi

    Hi Padma
    the std reports S_PL0_***** serve the purpose... You can browse SAP easy access menu under FI
    you can input PC or a group of PC as additional selection criteria
    Ajay M

  • Profit Center Groups Wise Report

    Hi Team,
    Is it possible to have GL Balance, Vendor and customer Balances on Profit Center Group Wise on basis of Plant to which few more plants are assigned.
    For Example:
    Company code is 1000
    Under Co. code 6 Plants are present ie; 2000, 3000, 4000, 5000,6000, 7000
    3000 and 4000 Plants reporting to 2000 plant 6000,7000 plants are reportting to 5000 plant
    for ex geographically you can imagine we have one comany code and uder that two main reporting centers are exists like south and north.
    For every plant we have 10  profit centers. To get the plant wise P&L and B/S we created  profit center groups and we are getting the reports in controlling but client require GL balances vendor balances Customer balances in FI on profit center group wise. (Both vendors balance FK01 & XK01, Customer balance FD01,XD01,  GL Account Balance of 2000,3000,4000 all combined)
    so i would like to know if we want FI reports like plant shall we create group profitcenter or we have some other option because p group wise  GL balnces customer balnces vendor balnces is must requyired for the client.
    Thanks,
    Madhu

    Hi
    You can check with below mentioned reports
    S_ALR_87013326 - Profit Center Group: Plan/Actual/Variance
    S_ALR_87013327 - Profit Center Comparison: Plan/Actual/Variance
    S_ALR_87013330 - Profit Center Group: Plan/Plan/Actual Versions
    S_ALR_87013332 - Profit Center Group: Current Period/Aggregated/Year
    S_ALR_87013334 - Profit Center Group: Compare Actual Quarters over 2 Years
    S_ALR_87013336 - Profit Center Group: Balance Sheet Accounts Plan/Actual/Variance
    S_ALR_87013337 - Profit Center Group: Key Figures
    S_ALR_87013339 - Profit Center Comparison: Return on Investment
    S_ALR_87009712 - Profit Center List: Plan/Actual
    S_ALR_87013340 - Profit Center Group: Plan/Actual/Variance
    S_ALR_87009726 - Profit Center Group: Plan/Actual/Variance by Origin
    S_ALR_87009734 - Profit Center Group: Plan/Plan/Variance
    S_ALR_87009717 - Profit Center Group: Quarterly Comparison of Actual Data
    S_ALR_87013342 - Profit Center: Statistical Key Figures
    Regards
    Praveen PC

  • Vendor Evaluation by Material and Material Group wise

    Dear Folks,
    Customer requirement is to see subcriterion level scores of Vendor
    Evaluation according to material, Material group wise. But the
    datasource provided by SAP is providing the data according to
    Purchasing Organisation level and Vendor level (0MM_PUR_VE_01).Is it
    Possible to break the scores according to material group and material
    as TC in r/3: ME6B provides ranking based on Main Criterion level
    scores. If possible, what is the logic?
    Thanks in Advance

    Hi Anil,
    Thanks for ur reply.
    But Customer requires vendor evaluation data through Automatic route.
    0MM_PUR_VE_02 caters to semi-automatic data which needs to be configured in r/3, and customer doesn't want to do that. Is there any other solution.

Maybe you are looking for

  • How to take multi disc cd and combine as one cd

    trying to take multi cds and combine as one cd to take up less space on my ipod touch! can anyone help?

  • Choice of web browser for MacBook

    I switched from a 20" iMac to a MacBook. I needed a portable. I noticed that on the smaller screen, the default fonts displayed by Safari were too small in some sites. If I made the text bigger, other sites looked odd because it was too big. The solu

  • Select music and all playlists are just gone....

    Opened my Itunes and all my playlists and select purchased and imported music is gone at random it looks like. This happened on Monday. I have VISTA. Any ideas for me? I have most backed up but not all.

  • Premiere CC to Encore CS6 (bitrate?)

    * A few times my media has been to big to fit the Disc (DVD & Bluray 25) when I export multiple Sequences from Premiere CC via AME to Encore CS6. Other times it looks like I could have upped the Bitrate/Quality Settings a little bit more and it would

  • Replacement iPods

    My iPod recently (last night) just stopped working. I phoned the help line and am waiting on the courier to arrive to send my iPod back to apple for servicing. I was wondering, as iPod photo (mine is a 20Gb) is no longer available in the apple store,