How to obtain most popular cities from my users table

Hi.
I've got a 'users' table:
USER_ID --- CITY_ID
1 ---- 32
2 ---- 20
3----- 32
4 ---- 32
5 ----- 17
I would like to obtain the most popular cities from this table, and the number of occurrences. Is this possible to make it easy with an SQL statement?
Thx

Here is an example using the emp demo table -
SQL> select deptno, count(*)
  2  from emp
  3  group by deptno
  4  order by count(*) desc;
    DEPTNO   COUNT(*)
        30          6
        20          5
        10          3You can find full details of aggregate functions like count, and group by and order by in the SQL Reference manual.

Similar Messages

  • How to read the hierarchy data from the same table using loop in AMDP method

    Hi All,
    We have a requirement to get the top partner from BUT050 table.
    Here the Top parent is nothing but the top most in the hierarchy of the partners from BUT050.
    Example:
    For partner 1234 (BUT050-PARTNER1) there is partner 3523(BUT050-PARTNER2) one level above
    For partner 3523(BUT050-PARTNER1)  there is partner 4544 (BUT050-PARTNER2) last level .
    so in this case for the partner 1234 the Top parent is 4544 .
    I have created AMDP Procedure method to get the top-parnet and below given is the logic implemented in AMDP method.
    Here i have implemented a recursive logic with the WHILE loop to get the top most hierarchy partner from the same table BUT050
    IV_Parent is the input partner and ev_top_parent is the output value.
    AMDP Procedure Method:
        DECLARE lv_date VARCHAR(8) := TO_VARCHAR (current_date, 'YYYYMMDD');
        DECLARE found INT := 1;
              iv_partner1 =  SELECT partner1 FROM but050
                              WHERE partner2 = iv_partner
                              AND reltyp = :iv_hierarchy
                              AND date_to >=  :lv_date
                              AND date_from <= :lv_date;
         WHILE found <> 0  do
           select partner1 into ev_top_parent from :iv_partner1;
                           iv_partner1 =  SELECT partner1 FROM but050
                           WHERE partner2 in ( select partner1 from :iv_partner1 where partner1 is not null)
                           AND reltyp = 'ZBP004'
                           AND date_to >= :lv_date
                           AND date_from <= :lv_date;
           select COUNT ( partner1 ) INTO found FROM :IV_PARTNER1;
        END WHILE;
    This method is working fine, but here it is only taking one single partner and getting the top parent as output.
    Now i would like to convert this mehtod so as to accept n number of partners (not one single partner) as input and should process each partner to get the top parent.
    Could anyone guide me how can i handle the given AMDP method further so as to work some how it is within another loop from other AMDP method.
    Thanks.
    Regards,
    Laxman.P

    Hi
    Go to SE11 and enter the hierarchy table name.
    /BIC/H....(infoobject name)...and execute the table and select table entry and delete all....
    Thanks
    TG

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • How do I move Contacts & Calendar from one User to another User on the same Macbook Pro?

    How do I move Contacts & Calendar from one User to another User on the same Macbook Pro? OSX 10.9.5

    is this second library in a different account on the computer?
    Look at Home Sharing.
    iTunes: How to share music and video - http://support.apple.com/kb/HT2688 - about Music Sharing and Home Sharing
    Home Sharing Support page - http://www.apple.com/support/homesharing/
    iTunes: Setting up Home Sharing on your computer - http://support.apple.com/kb/HT4620
    iTunes Home Sharing now works between users on same computer - https://discussions.apple.com/thread/3865597

  • How do I move imove content from one user to another on the same computer?

    We bought our Macbook pro about six months ago. We made the mistake of creating two users for it (my husband and myslef) but bow we only log in under my user name. The problem is we originally imported all of our video camera content to his "log in" and now it is in his imovie folder, and not mine. I want to make a movie on my log in with the fottage that we imported to his. So, how do I get video content from one users login on the SAME computer to the other log in users? I cannot seem to move it for the life of me. I did not expect this to be so difficult.

    Hi,
    You need to log into his account and look, under the Movies folder, for iMovie Events. Inside, you'll find folders with the events names and still further will be the movie itself. Copy each to an external media or use the Shared folder so both accounts can reference them.
    Another option would be to attach an external HD and via iMovie (Events Library pane) move them to the new disk. You would preserve the thumbnails and analysis already performed on the videos.
    Good luck!

  • How to open attachments in email from windows users

    How to open attachments in email from windows users.

    That would be totally dependent on what type of file has been sent. What is the windows user sending to you?

  • How to obtain Sync Recovery Key from Android Firefox?

    Desktop sync is broken and instructs to obtain "Your Recovery Key" from a working device. Only working device is Android Firefox. What is the magic incantation to get Firefox (v21 beta) on Android to reveal the needed sync Recovery Key?

    You can use:
    *Android OS > Settings > Accounts > Firefox Sync > Pair a new Device
    This will give you a 12-character pairing key the you can enter in the desktop computer.
    You can look at this version of the about:synckey extension that I have modified to show the sync key in current Firefox versions (desktop and mobile).
    * http://www.freefilehosting.net/aboutsynckey-11-fnfx
    * [[/questions/942893]]

  • How to run insert/update/delete from CDC Change table to target using OWB

    I am planning to set up CDC and publish CDC change table as source data into to OWB. I have come across where I am confused how to apply changes from CDC change table to target database using OWB. For i.e. change tables is containing information like
    operation$, cscn$,commit_timestamp$,xidusn$,....,list of column name
    D,12323223,8/28/2008 1:44:32PM,24,.....,list of column value that have to be deleted from target
    UO,12323224,8/28/2008 1:45:23PM,24,.....,list of column value that have to be updated in target.
    Please advice or give me some hint. Thank you.

    Hi,
    you can wait for 11gR2 with CDC integration or build most of the code outside the owb. To use CDC you must do this things (http://www.oracle.com/technology/oramag/oracle/03-nov/o63tech_bi.html):
    1. Identify the source tables.
    2. Set up a publisher.
    3. Create change tables.
    4. Set up a subscriber.
    5. Subscribe to the source tables, and activate the subscription.
    6. Set up the CDC window.
    7. Prepare a subscriber view.
    8. Access data from the change tables.
    9. Drop the subscriber view, and purge the CDC window.
    10. Repeat steps 6 through 9 to see new data.
    You can do only a few of this inside owb, most of it must be done outside.
    Regards,
    Detlef

  • How to retrieve a statistic sample from a database table

    Hi experts,
    Let's say I have a 100.000 rows table and I want to take a representative statistical sample from that table.
    Say, it should be 5% (or 5000 rows).
    Question is: How to ensure that the sample is representative?
    This is not guaranteed by UP TO N ROWS because the database selects without having an order by  or WHERE starting reading the first db blocks until it reaches  the limit of 5000 rows.
    SELECT * UP TO 5000 rows into table .... from ZSAMPLE.
    This means I miss mostly of the records in the table, hence the sample is not representative.
    Do you ever encounter such a problem?

    You could SELECT (with package size if desired) into an internal table.  Then:
    Select * from table into internal table........
      package size 10000.  "not really necessary for 100000 row table
    *Initialize a counter of type i.
      lv_counter = 0.
    loop at the internal table.
      lv_counter = lv_counter + 1.
       if lv_counter lt 20. "1 in 20 = 5%
         delete internal table. "drop this row.
       elseif lv_counter eq 20.
         lv_counter = 0. 
    endif.
    endloop.
    endselect.  "if you used package size.
    at the end you would have kept every 1 out of every 20 records from your original table select.  Be sure to use a package size (if needed ) that is an exact multiple of 20.  To futher randomize the table, you could sort on some field that has random values, etc. before doing the every 20th record retention.

  • How to open a new page from a Spry Table click, with element info?

    Hello, Spry experts!
    This is probably simple, but I've searched for hours and can't find what I need. I'm using Dreamweaver CS4 and Spry 1.6.1 to create a simple Spry Table from an XML data set using PHP as my back end.  I've used Dreamweaver's Insert->Spry->Spry Data Set to create everything, and the table is working fine.  Colors, clicks, sorts, etc., are all working correctly as expected.
    What I want is to be able to add a behavior such that when a table row is clicked, I can open a new page.  Moreover, I want to pass a parameter from the table to the new page, like http://www.mydomain.com/newpage.php?aid=12345 or whatever.
    So, for example, my table has two columns, "a_id" and "a_name", and my repeat region looks like this:
    <div spry:region="xml_assignments">
    <table width="500">
    <tr>
    <th spry:sort="a_id" class="spry_header">ID</th>
    <th spry:sort="a_name" class="spry_header">Assignment</th>
    </tr>
    <tr spry:repeat="xml_assignments" spry:setrow="xml_assignments" spry:odd="spry_odd" spry:even="spry_even" spry:hover="spry_hover" spry:select="spry_select">
    <td>{a_id}</td>
    <td>{a_name}</td>
    </tr>
    </table>
    </div>
    What I want is to be able to open an entirely new URL, passing the value of the {a_id} in the selected row as a parameter to the new URL, as in something like:  http://www.mydomain.com/newpage.php?aid={a_id}
    So my questions are: 
    1. How best to apply the action to the table?  Add an onclick to the tr tag?  Something else?
    2. How to extract the {a_id} value from the current row and pass it as a parameter to the action?
    Or maybe just take another approach entirely?
    I know that I can make the actual text in the table cells hyperlinks, and use them to link to the new page, which is fine.  The desire here is just to make it so that the user can click "anywhere" on the table row (as they can currently do with the spry:select behavior) and have the link kick off, whether they actually click on the linked text or somewhere in the row where there is no text.
    I'm sure this is obvious and simple, but I'm new to this level of Spry detail, and my brain is fried from hunting.  Any guidance will be gratefully appreciated!
    Glen Barney

    I found the answer myself, after posting this, of course!
    I changed:
    <tr spry:repeat="xml_assignments" spry:setrow="xml_assignments" spry:odd="spry_odd" spry:even="spry_even" spry:hover="spry_hover" spry:select="spry_select">
    to
    <tr spry:repeat="xml_assignments" spry:setrow="xml_assignments" spry:odd="spry_odd" spry:even="spry_even" spry:hover="spry_hover" spry:select="spry_select" onclick="window.location.href='./newpage.php?aid={a_id}';">
    Basically just added the onclick parameter...
    And it all just worked!

  • How do I move a folder from one user to another

    I copied folders and files from a PC to my new Mac Pro (running Yosemite).  I am now trying to figure out how to move some some of the folders transferred in from my old PC from one user to another on the Mac.  I am a first time user of a Mac desktop so thanks of any help!

    Choose Go to Folder from the Finder's Go menu, provide /Users/Shared/ as the path, drag them there, and then into the desired account's home folder.
    (119245)

  • How do I copy a folder from one user to another?

    Using Lion, I had to "re-migrate" my photo folder from my old MacBook Pro to my new MacBook Pro, but it required me to set up a new user on the new computer.  Now I need to get the photo folder from user2 folder to user1.  How does one do that efficiently?

    See  Transferring files from one User Account to another, especially the blue box.

  • How do I access time machine from different user account

    Hi there.
    Last week I had to take my comupter into the local Apple Store because I was having problems with Boot Camp.  The genius at the store had to delete everything from my hard drive and reinstall it from my external hard drive.  As part of the process she created a "Apple" user account.  I now want to restore some files (unrelated to this Boot Camp story) from my time machine archive.  However, all the files prior to this Apple Store encounter are red -- and it says I do not have permission to view them.  When I click "get info" it says that the "Apple" account has the read/write access to them and the option to unlock them is greyed out.  How can I get these files from the archive and get them onto my main user account where they belong?  The "Apple" account does not have a password so I think I can easily log on as that account, but I don't know where to go from there.
    PS The files in question are iTunes libraries.
    Thanks for your help.

    Ok, I fixed it.  Here's what I did.
    I logged into my computer under the Apple account.  Then I went into Time Machine.  I found my old files under Users-->"my main account".  I was able to restore those files to Users-->Shared.  Then I was able to log back into "my main account" and retrieve the files from the shared folder.  It worked!  Hope this helps someone else some time!

  • How do I include/show data from a child table in a Modal Window?

    How do I show data from a child table in a Modal Window?
    I have an application where each customer might have multiple addresses and phone numbers which are stored in child tables.  When I show the customer in a record on a screen I can place a Modal Window button on the screen which can be pushed at runtime
    to display detail information for the particular customer parent table which works great. However, I would also like to display the data from the address and phone number child tables. Is there a way to do that?  Or can I just launch a hole separate screen
    which would automatically display the needed data for the particular customer? If yes, how? 
    Thank you for any help.

    I am not even sure how to describe my situation in such a way that this forum incident would be of benefit to other people as I think it is fairly unconventional. 
    The “add contactaddress” link does not show up on the right.  
    The contactaddress table is a child of the contact table. 
    The contact table is a child of the contactlink table.
    And the contactlink table is a child of the person table.
    I have it set up this way because the contact in the contact table may be a contact to multiple persons in the person table and I do not want to re-enter the contact info every time the contact is used. 
    In the list detail screen of the person table I can see the contactlink child collection so that I can see the name of the person in the contact table at runtime. However, the contactaddress collection is not related to the person table so it does not show
    up on the right hand side of the design screen as an “add contactaddress”; nor is there “add contact” link.
    What I would like to happen during runtime is that it is not necessary to switch screens from the person list detail screen to a contact list detail screen to see the addresses and phone numbers for the contact.
     Is my setup unnecessarily convoluted? Is there a better way? Please see the two snapshots below.
    Perhaps there is a way to call up a Detail screen from the List Detail at runtime? 
    Anyway, if you are still reading, thank you very much for your help.   
    jjjjj

  • How to get PO CHANGE HISTORY from back end tables?

    Hi All,
    I need to get the PO Change history from the back end reason being users want to see not only the change made but who made the changes on those PO's. The PO change history.html doesnot give the information of the user who made changes to the PO. Can any one provide me the query involved in this html page. I can add the updated_by column to that. I built a query already but it is not giving me the field altered on the PO Line.
    I learnt that we can get the information from the archive tables but my question is how to know which field has been changed from the original PO to the revised PO. I am unable to figure out if that revision is for Unit Price change or amount change or Bill to change etc. i.e., as it shows in PO change History html page I need to see which field is altered on a particular PO. Is that possible?
    Thanks for your help!
    Prathima
    Message was edited by:
    Prathima

    Hi Anil,
    Turning Audit on PO_LINES_ALL helped to track the changes. I have a problem though.
    In the sense - Below is the query I created to track changes on Unit Price of a Po Line.
    SELECT
    poh.segment1 po_num
    ,pol.line_num po_line_num
    ,pola.unit_price price_changed_from
    ,pol.unit_price price_changed_to
    ,fnd1.description created_by
    ,fnd.description last_updated_by
    ,fnd2.description previously_updated_by
    --,decode(pola.audit_transaction_type,'U','UPDATE','I','INSERT') audit_transaction_type
    ,pol.last_update_date
    FROM po.po_lines_all_a pola,po.po_lines_all pol,apps.fnd_user fnd,apps.fnd_user fnd1,po.po_headers_all poh,apps.fnd_user fnd2
    WHERE pola.po_line_id = pol.po_line_id
    AND pola.audit_transaction_type = 'U'
    and poh.po_header_id = pol.po_header_id
    AND fnd.user_name = pola.audit_user_name
    and pola.unit_price is not null
    and fnd1.user_id = pol.created_by
    and fnd2.user_id(+) = pola.LAST_UPDATED_BY
    Now the problem is
    When I update a line twice. intially I changed the unitprice value of line 4 from .72 to 0.8 and later I changed it back to 0.8 to 0.72. Intial Changed to 0.72 shuld be 0.8 but it changed to 0.72 as it is pulling from po_lines_all table. How can you capture that changed to???
    po_num Line Changed from Changed to
    26603     4     0.72000      0.72000
    26603     4     0.80000     0.72000
    Please help.
    Thanks,
    Prathima

Maybe you are looking for

  • Regarding downloading file on application server ?

    i am using open data set and close data set to create file on application server. the program is compiling fine, but when i execute it, it throws a dump saying DATASET_NOT_OPEN  , it says that the file is not open. when i check value of sy-sub-rc it

  • Oracle BI  Web Services "SecurityServices.createAccount" Failure

    I am attempting to create a script to add potentially 1200 accounts to our BI presentation server. If this is not the best method for doing this please suggest something else. I am trying to use the Webservice interface to call the securityservices.c

  • Report painter dump while execution

    Hi, I am executiing report developed using report writer. It is giving error when specific criteria given as input for rest of the criteria is is working fine. What i analysised while debugging is it fills some matrix, matrix has fields like prev nod

  • (Another) Recent Exchange Upgrade - Slow Speeds

    Since my exchange was upgraded 9 days ago, I have had diabolical (less than 1meg) download speeds. I appreciate the time to settle down can be up to 10 days, but my speed seems to be getting worse, not better. I don't have a Hub, I'm using a d-link D

  • Mass Maintenance of EDI Partner Profiles

    Hello SDN folks,   my customer is a large multinational - and they are beginning to run into difficulties in the management of their EDI partner profiles. The problem is that there are thousands of external parties that must be communicated to via ID