Output not as per requirement

Hi there,
I am running a query:
select distinct(state_code),count(*),hldy_str from hol,sol where cal_b2k_id=sol_id
and mmyyyy='122009'
group by state_code,hldy_str
order by state_code
is output is something like :
HAR 63 Y Y Y Y Y
HP 15 Y Y Y Y
JHK 44 Y Y Y Y YY
JHK 19 Y Y Y Y Y YY
JNK 4 YY Y Y Y YY
KAR 127 Y Y Y Y Y
KER 188 Y Y Y Y Y
KER 1 Y Y Y Y YY
MAH 1 Y Y Y Y
MAH 410 Y Y Y Y Y
MAH 1 Y Y YY Y Y
MAH 1
MEGH 4 Y YY Y Y YYYY Y
Now If you notice that there are two rows for JHK, 3 for MAH what I want is to have only one row in which high value for the 2nd col should come
Pls help

Hi,
I see: you want one row per state_code, and the highest count for that state.
Do you want hldy_str? If so, which one, or do you want some kind of aggregate?
What if there's a tie for the highest count in some state?
Depending on your requirements, you may have to change this:
WITH     group_by_2_columns     AS
     SELECT       state_code     -- no need for DISTINCT when you select all GROUP BY columns
     ,       COUNT (*)          AS cnt
     ,       hldy_str
     ,       RANK () OVER ( PARTITION BY  state_code
                           ORDER BY          COUNT (*)     DESC
                           ,          hldy_str
                         )     AS rnum
     FROM       hol
     ,       sol
     where       cal_b2k_id     = sol_id
     AND       mmyyyy     = '122009'
     GROUP BY  state_code
     ,       hldy_str
SELECT       state_code
,       cnt
,       hldy_str
FROM       group_by_2_columns
WHERE       rnum     = 1
ORDER BY  state_code
;The query above includes the entire row that had the highest count for each state_cd.
If there is a tie, it takes all of the tying rows. Change RANK to ROW_NUMBER if you want only one of them.
Notice that the sub-query (group_by_2_columns) is almost exactly what you posted.
The main query just picks the top row for each state_code from your original results.
I hope this answers your question.
If not, post CREATE TABLE and INSERT statements for your sample data, and the results you want from that data.

Similar Messages

  • Spool output not as per the requirement.

    I am using REUSE_ALV_GRID_DISPLAY with  31 columns in the foreground report . The report executes fine in the foreground. Even the spool is created fine when run on the background. Spool output is breaking to the second row after 25th column. But the client needs the spool output for all 31 columns in the same line. Can anyone help me that how can we do the same?
    I am using  X_65_255 format while running in background. My report has line-size of 260. I tried extending the line-size too. But there is no difference in the output. Even changing the setting to different page format was not helpful.
    Thanking you all in advance and hoping for quick solution.
    Ranjan

    1.What type of printer being used?
    2.Any reserve statement used in ur program?
    3.Try with X_65_132
    4. Is this happning only for this report print out?

  • Credit Management- KRML Output not generated for Sales Order ( v.v.u.)

    <u>Credit Management - Credit control check at Sales order Level</u>
    While saving the Sales order,which failed the Credit check ( As per Automatic Credit Check Settings), there is no output generated for output type KRML, for Partner Fn KB/KM. Normally,If credit check is NOK, then while saving the sales order, an internal mail is sent to the SAP office inbox of the Credit representative ( KB/KM). There is option for an external send also. The problem faced by us is that, the mail is not going in SAP Office inbox in quality server , it is going in developement server.We checked in table NAST that the Output for KRML (o/p type) is not generated. Kindly suggest what could be the reason.
    Regards
    Sunil Kumar

    Dear Mr. Gauravjit,
    Thank you for your valuable reply.
    At the Extra-Output-Header-edit-goto-det analysis ,system give message as KRML o/p is not generated since Requirement 009 is not being fulfilled. But we checked the VBUK-CMGST = B is satisfied. Still the o/p not generated!
    Also , in VV11 we maintained the Cond Records. Still the o/p is not coming.
    The output is coming in Devlopment , but in Quality the output is not coming.
    Can anybody please help !
    P.S. I am colleague of Mr. Sunil Kumar, and reply on behalf of him.
    With Best Regards,
    Kaustuv

  • Is it possible to create a Webservice in BI which takes XML as an input and gives PDF as output with an additional requirement that Siebel expecting the XSD from BI to send data in the BI requested format

    Is it possible to create a Webservice in BI which takes XML as an input and gives PDF as output with an additional requirement that Siebel expecting the XSD from BI to send data in the BI requested format. Siebel wants to send the data as xml to BI but not sure of the BI capabilities on giving WSDL embedded with XSD (input is a hierarchical)

    Hi All,
    I am able to fulfil above requirement. Now I am stuck at below point. Need your help!
    Is there any way to UPDATE the XML file attached to a Data Definition (XML Publisher > Data Definition) using a standard package or procedure call or may be an API from backend? I am creating an XML dynamically and I want to attach it to its Data Definition programmatically using SQL.
    Please let me know if there is any oracle functionality to do this.
    If not, please let me know the standard directories on application/database server where the XML files attached to Data Definitions are stored.
    For eg, /$APPL_TOP/ar/1.0/sql or something.
    Regards,
    Swapnil K.

  • Error message when opening adobe premier 10 saved film file , this file is not supported or required codec not installed

    Hi
    Can any one help, keep getting error message,error message when opening adobe premier 10 film file , this file is not supported or required codec not installed,
    Thanks
    Colin65

    Steve,
    Not to sure what type AVI files they are, the storage devise is at present offshore on a job.
    Can you clarify, if you edit/import video footage with adobe premiere 10 and then create a file, the file or the original raw footage is not stored on computer for re-use, if it is stored, is it stored in the original format.
    Also please find details of storage devise,
    Dogcam Portable Media Center PMC-500r
    Quick DetailsModel Number:PMC-500R
    SpecificationsPMC-500R20G/40G Portable Multimedia PlayerPMC-500R 20G/40G Portable Multimedia Player, Supports
    PMC-500R20G/40G Portable Multimedia PlayerPMC-500R 20G/40G Portable Multimedia Player, Supports MPEG-4 File FormatsKey Specifications/Special Features:Video recorder: supports digital video recoding in MPEG4 from Line-in Video playback: supports MPEG4 (AVI), MPEG1 (.MPG), DVD (MPEG2,.VOB) Supports MPEG4 with 720 x 480 at 30 Frames/s MPEG4 movie playing with Fast Forward, Fast Reverse, Time search function Music playback: supports MP3, WMA, WAV Music playing with play list function MP3 ID3 information and sorting, LRC Music playing with repeat, shuffle playing function Photos view: supports JPEG and slide show, rotate, nail view Easy backup of photos in digital camera -USB OTG technology Audio recording: continues recording for over 40 hours High resolution output for HDTV (Y, U, V output; 704 x 480 (N) or 704 x 576 (P), at 25/30 frames/s) Super dlim size: 126 x 79 x 22.5 mm Games E-book with bookmark, auto turning page, page search function File browser function with Copy, Delete, HDD capacity information With 3.5" LCD QVGA TFT panel (960 x 240) Long time battery running (over 5 hours for video, and 9 hours for audio) 1.8" 20G/40G storage capacity High fidelity sound with good earphoneCompass Electronics Co.,

  • Why is RoboHelp not displaying the required data content of .chm when linked as Help in my App ?

    Gorgeous Hello All,
    Has anyone encountered the below-said show- stopper. Another BIG TIME help required, will help me in tremendous fashion.
    Am using Adobe RoboHelp, Version 10 and IE version being 10.
    In my local machine :
    1.)I have completed my technical writing courtesy Design editor
    2.)Generating chm File : View -> Pods –> Single Source Layouts -> Right Click on Microsoft HTML Help -> Tagged Set as Primary Layout
    3.)Generating Primary Layout : File -> Generate -> Primary Layout (Microsoft HTML Help)…
    4.)Viewing Primary Layout : File -> View -> Primary Layout
    Everything works FANTASTICALLY till here with the required output (as Hide, Back, Refresh, Home, Print, Options, Contents, Index, Search, Glossary and with the data contents)
    Show Stopper, At my Application Server :
    5.)I copy the entire robohelp project folder from my local machine to my application Server path
    6.)My Application has been developed in ASP .NET, Version 4.0.
    7.)Help link has been created in this application wherein here the file name of < >.chm has been linked in the code to be read from the  Server’s RoboHelp project folder\!SSL!\ Microsoft_HTML_Help\
    8.)I login into my above-said application -> click on the Help page -> Displays the required structure /buttons as Hide, Back, Refresh, Home, Print, Options, Contents, Index, Search, Glossary
    a.)Clicking on any of the Books or Topics appearing beneath Contents : The System prompts out with error cautionary message called “ Navigation to the webpage was cancelled. What you can try: Retype the address ”
    *** This is a huge SHOW-STOPPER. I spent plenty of hours on this, but unable to deciper with a solution at all) ***
    ( Note : Am able to directly open and read the required data contents by Clicking on any of the Books or Topics appearing beneath Contents from Server’s RoboHelp project folder\!SSL!\ Microsoft_HTML_Help\ < >.chm )
    Why is the RoboHelp not displaying the required data contents of <>.chm when linked as Help in my Application ?
    Cheese – Vipin Nambiar

    If you looked at the error message and searched the forum, you should find the answer as this is a problem that started in 2005. You should not run CHM files from a server and cannot without editing the users registry. See the page below.
    http://www.grainge.org/pages/authoring/chm_mspatch/896358.htm
    All along your questions have been based on webhelp, why suddenly are we going go CHMs.
    See Snippets on my site for the correct form of help to use in different scenarios.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • When i try to open itunes i now get an error message saying i do not have the required components installed error number 45075?

    when i try to open itunes i now get an error message saying i do not have the required components installed error number 45075?

    Just in case the component being referenced is not part of iTunes but is rather part of one of the other related programs, it might be worth trying a complete uninstall/reinstall of iTunes and related componentry, as per the following troubleshooting document:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7

  • The stock consumption as per expiry date and not as per availability date

    Hi All,
    We had a requirement like below for our client:
    While creating batch in ECC we put the expiry date for the batch as per the business requirement.
    Suppose batch creation date: 01.01.2011
    If in case the SKU shelf life is 1 year the logical expiry date should be 31.12.2011.
    But here user can put any expiry date (there is genuine business reasons behind that), so for one SKU for one Availability date of the batch we can have 2 expiry date.
    Please see below one example for the same:
                         EXPIRY DATE                 SHELF LIFE                    AVL DATE
    batch-1        08.10.2012                       720                              19.10.2010
    batch-2        06.06.2012                       365                              12.06.2011
    batch-3        01.08.2012                       360                              03.08.2011
    In the above case the SKU which is available first is having a long expiry period and vice versa.
    As per standard SAP the stock which is available first will be consumed first. So as per standard SAP batch1 will be consumed first than batch-2 and than batch-3.
    But our requirement is to consume stock based on the expiry date of the stock.So the stock which is going to expire first will be consumed first. In the above scenario the consumption should happen like batch-2 first than batch-3 and than batch-1.
    The client requirement is to consume the stock as per the expiry date and not as per the Availability date (this is what happens in the usual scenario).
    Could you please suggest how to incorporate this?
    Thanks in Advance,
    Mukesh Pandey

    Hi Mani,
    Thanks for your prompt reply.
    I tried using the characteristic for Expiry date as the sort criteria as per sap note 377186.
    After doing the changes in the structure as suggested by SAP note i was able to see this characteristics as one of the sorting criteria. But when I am trying to create pegging relationship between demand and supply element he message i am gtting is "MAX_SL_DATE" can not be used as a sorting criteria in a fix pegging.
    System is just ignoring it.
    We have batch managed stock here and stock availability date is batch creation date.But since we are manually creating batch in ECC and cifing it to APO we are getting scenarios where for the same creation date of batches we have different expiry dates.
    I hope i am clear now.
    Could you please suggest any other option as sorting is not working .
    Regards,
    Mukesh Pandey

  • Start routine: only once per teh load but not once per data packet

    Hi,
    I would like to execute some code in start routine (in update rules) only once per the load but not once per the data packet.
    How can I implement this.
    Regards,

    I once had that same requirement, but in a datasource in R3. I'm not sure if the same solution would work in BW, though. I used a memory id to keep the variable value between packets:
    DATA: ... n_globalvar TYPE n ...
    then I added...
    IMPORT n_globalvar FROM MEMORY ID 'ZMEMID01'.
    ...at the start of the routine to retrieve to the variable the value from the memory id.
    At the end of the code, I exported the variable back to the same memory id...
    EXPORT n_globalvar to MEMORY ID 'ZMEMID01'.

  • We apologize for this inconvenience; however, your system does not meet the requirements necessary to view our media presentation.  I keep getting this message trying to view how to videos on my new iPad mini, does the new full size iPad have the same lim

    'We apologize for this inconvenience; however, your system does not meet the requirements necessary to view our media presentation'. I just received the iPad mini and get this message when I try to view videos.  Does the full size iPad support video play back?

    iPads have the same video requirements. What is the source of the video - streaming, download, from video camera?
    Pad2, the new iPad Supported Video Formats & Movie Formats
    H.264 video up to 1080p, 30 frames per second, High Profile level 4.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;
    MPEG-4 video up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;
    Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format
     Cheers, Tom

  • Open Purchase Orders not considered as requirement for MRP Run

    Hi ,
    We are facing a issue of Open Purchase orders not appeared in Stock requirements list and also it is not considered as requirement for MRP Run against reservation.
    As aresult for a reservation demand of 10 units we are ending with Open POs 10 units and a additional planned order 10 units.
    Material Type : ERSA
    MRP Type : PD (or VB)
    Lot size : EX (  HB if MRP Type is VB)
    Could you please throw some light to correct our settings to MRP to consider Open POs?
    Saravanan

    Can you check to see if there is a re-order point set up for this materia? That could be causing the problem too.

  • Scheduling Agreement -Schedule line should not pass the requirement to MRP

    Hi Friends!
    As we all know the scheduling agreements is outline agreement with future schedule lines, with this system will  pass the requirements to MRP for the schedule line which is even after 5 years, so my requirement is  if the schedule line date is above 15 days from the current date then requirement should not pass to MRP. 
    solution which we gave is, SA initially will determine the schedule line category as  CN (which will not transfer the requirement) and  a batch job program will run daily and it will check for each schedule line if any of the schedule is with in the 15 days from the current date then it will change the schedule line category from CN to CP. 
    Now the problem is , by using Batch Job which program I have to call to change the schedule line category?????
    1. we tried BAPI_SALESORDER_CHANGE but when we are changing the CN to CP it is not performing ATP where as if we do manually it is performing.
    2. we tried BDC but here also we facing some strange problem i.e. while recording the ATP screen is not populating where it is coming while doing manual.
    Can someone let me know which one program we should call in Batch job to do this change.
    Regards
    Nath

    Hi nath,
    i also failed in changing shedule line category in userexit and in BAPI.
    in one case, i succeded in doing it with a bdc after MV45AFZZ / userexit_save just bevore the datas are reset but after the commit-work is processed.
    the other possibility is, to change the accepted amount in userexit RV03VFZZ / USEREXIT_AVAILABILITY_OUT.
    3. possibility is, to block the order with a delivery - block , same as the credit-control-block. This block can be set in MV45AFZZ or perhaps in BAPI too.
    hans

  • HT204266 Hi... I bought an app from app store... It turned around to be a false app and not as per the description. App dev page is a fraud. How can I get a refund?

    Hi... I bought an app from app store... It turned around to be a false app and not as per the description. App dev page is a fraud. How can I get a refund?

    Welcome to the Apple community.
    Select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History.

  • Error 1074395241: The template descriptor does not contain data required for rotation-invariant matching.

    Hello all,
    I am using the IMAQ Match Pattern 4 to detect the rotation angle of a template image. However, it shows the error: "Error 1074395241: The template descriptor does not contain data required for rotation-invariant matching." What is the problem exactly? How to solve this? The details are explained below.
    My project is a little bit complicated. Part of the block diagram containing the IMAQ Match Pattern 4 is shown below:
    The source image is a series of frames of images read from an AVI video (I used a for loop to process the images frame by frame). The template image is a selected region of the first frame. So it means, the user selected the object of ineterst in the first frame of the video, and in each of the following frames, we need to find the matched object of interest & determine its rotation angle. When I run the block diagram shown above, it does not have any error. However, it shows the rotation angle as zero no matter what it "really" is. Therefore, I changed the block diagram by adding the parameters, shown below:
    But in this case, when I run it, it shows the error that I have indicated in the subject line.
    If you need more details about my project to identify the problem, please let me know.
    Thanks in advance.
    Solved!
    Go to Solution.

    -Please go through pattern matching example which comes along with labview fiirst
    Go to labview Help>>Find Examples and you can search for example.
    -You have create template with angle range and what type of pattern matching you want use.
    -For this you have to use IMAQ Learn Pattern before using IMAQ Match Pattern 4
    Refer :http://zone.ni.com/reference/en-XX/help/370281U-01/imaqvision/imaq_match_pattern_4/
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13

  • HT3275 Since updating OS to Mountain Lion from leopard, I get the following error message when trying to backup with time machine on external drive.  Could not complete backup to media share.  The network backup disk does not support the required AFP feat

    Since updating OS to Mountain Lion from leopard, I get the following error message when trying to backup with time machine on external drive.  "Could not complete backup to media share.  The network backup disk does not support the required AFP features."  What are AFP features and how do I get Time Machine to backup to my current external backup?

    This means that your NAS does not support the required encryption. Update your NAS to the latest firmware or ditch it and buy a Time Capsule (they are the most reliable when using TM).

Maybe you are looking for

  • RFC ERROR IN WEB DYNPRO

    Hi I m Doing Web Dynpro Program For DMS Project There Is Some Problem Occuring In Default Function Module ARCHIVOBJECT_CREATE_FILE And The Error Msg Is : Cannot Call RFC Program And No Return Possi By Srinivasan.R

  • Current date in web dynpro's java interactive forms

    Hi experts!! In multiple interactive forms i am using a date-time field with: runtime property set to current date/time. Even though i use as display pattern  & edit pattern YYYY-MM-DD it still shows the time.. What am i doing wrong???? Thanx in adva

  • My new Ipod Touch 4 gives a overheating warning the second i want to use it .

    My new Ipod Touch 4 gives a overheating warning the second i want to use it or when i connect it to the loader. The ipod isn't even warm when it happens.

  • JSFCRUD JPA app can't be deployed to another glassfish 2.1 server

    OK, my colleague wrote a JSF Crud app based on this tutorial: http://www.netbeans.org/kb/docs/web/jsf-jpa-crud-wizard.html It works fine when I build and run it on my sandbox app server, but when I try to deploy it to our company test app server, the

  • NAC Guest Server syslog correlation

    Hi all. I have a question regarding the syslog correlation on the Guest Server. I use a Fortigate 310B as radius client which is sending its syslogs to the Guest Server. But when I know look in the Access Reports there's nothing displayed. Does anyon