Need query... help me any one...

Hi,
i have the table like this,
| city | caste | cnt |
| 1 | 1 | 2 |
| 1 | 2 | 3 |
| 2 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 1 | 3 |
| 3 | 3 | 1 |
i want to select the top caste which is having the most cnt value for the each city.
expecting output
| city | caste | cnt |
| 1 | 2 | 3 |
| 2 | 2 | 2 |
| 3 | 1 | 3 |
Can you any one help me...?
Thanks,
S.Ashokkumar.

Hi,
i have tried like this...
select t.city,t.caste,max(t.cnt) as mm from (
     select city,caste,count(caste) as cnt from city group by city,caste)t
group by t.city
order by count(t.city) desc
it gives the wrong result set.
Is it correct or not?
Thanks
S.Ashokkumar.

Similar Messages

  • My ipad is stolen ,, and i want to reopen find my ipad application because as i know once the ipad switched off and switched on again the application needs to be reopened ,, any one can help me please to find my ipad again

    my ipad is stolen ,, and i want to reopen find my ipad application because as i know once the ipad switched off and switched on again the application needs to be reopened ,, any one can help me please to find my ipad again

    Stolen
    http://support.apple.com/kb/HT5668
    Erase iPad
    http://support.apple.com/kb/ph2701
    Lost Mode
    http://support.apple.com/kb/PH2700
    Reporting lost or stolen iPad
    http://support.apple.com/kb/HT2526

  • I jailbroke my ipod and its in recovery mode i cant take it out of it and i cant restore becasue i changes host to sariks sever i need help can any one help me

    i cant take it out of it and i cant restore becasue i changes host to sariks sever i need help can any one help me please please i just got my ipod i realy need help

    Sorry, due to the Terms of Use, problems with jailbroken devices can't be discussed here.

  • Hi..............I Stuk up with a problem in JTree Please, help me any one..

    Hi,
    I created a JTree where the DefaultMutableTreeNode is created at run time and for this node, the leaf items are added dynamically.....Now my problem is, I should get a popup menu when i click on the treenode particularly-----
    * Node1
    -------Node11
    -------Child1
    In this I want a popup only for the Node11 & its child elements if there is any Node2 also i don't want a popup and also for Node1 i don't want, when I am trying this I am getting the Popup to all nodes and child elements, please, help me any one who cross over this problem.............
    Thanks In Advance,
    Regards,
    Sarikakiran

    Firstly, do you know how to detect the right click? (Use a MouseListener.)
    When you receive the MouseEvent for the right-click, you can get the coordinates of the click (i.e. where on the JTree the mouse was clicked).
    You can then use JTree.getPathForLocation to get the path for the clicked node, which is a TreePath object. Use TreePath.getLastPathComponent to find which node was actually clicked on.
    Having determined which node was clicked, you can then make a decision about whether to show a popup menu.

  • I have a hp photosmart B8550 that has stopped printing black. Any help from any one?

    i have a hp photosmart B8550 that has stopped printing black.  I put in a new black cartridge, but still no luck.  i am about ready to trash the unit.  It never has worked well and uses a lot of ink.  Any help from any one?

    Hi sydnoid_615 
    Sorry to hear that you are having this issue and I hope you are otherwise doing well;
    What Operating System?
    If windows Xp or later try this  HP Hardware Diagnostic Utility
    Veriify the printer firware and software up to date  Go Here select your OS and verify 
    How your printer is connected to your computer USB, Wireless, Ethernet ,ETC)
    if networked check the firware of the printer is the latest as well
    Hope it hepls;
    RobertoR
    You can say THANKS by clicking the KUDOS STAR. If my suggestion resolves your issue Mark as a "SOLUTION" this way others can benefit Thanks in Advance!

  • I need your help with buying one of your software programs.

    I need your help with buying one of your software programs.
    First of all I do not want to join this “Creative Cloud” for a monthly plan.
    Adobe Illustrator CS6 is what I am wanting but every time I click on the buy button is keeps sending me to a rent page to use but I don’t want this I want to buy it program for my own use. I don’t want to rent it I want to buy it like all the other Adobe software programs that I have bought from you in the past.
    Can you help with problem?
    Tim Adams
    [email protected]

    You can buy CS6 from this page
    Creative Suite 6

  • My iphone 3gs downgrade 5.0 to 4.33 and unlock with redsnow but network no  help me any one pls

    my iphone 3gs downgrade 5.0 to 4.33 and unlock with redsnow but network no  help me any one pls

    hi
    dear
    ......downgrade is currect   use ireb tinyumberla edit host and itune  no any error

  • Posiible to limit query time for any one query

    Hi,
    Using 11.2.0.3
    We have a third-party web-based reporting tool where sql queries are initiated on the database- sometimes the user kills the browser session and query still runs on the database.
    Is it possible ata dtabase level to set max time any one query can run e.g. no query over n hours. This would help kill such queries.
    Also is it possible to cap individual queries to say one query can never use more than n% of cpu, ram available?
    Thanks

    user5716448 wrote:
    Hi,
    Using 11.2.0.3
    We have a third-party web-based reporting tool where sql queries are initiated on the database- sometimes the user kills the browser session and query still runs on the database.
    Is it possible ata dtabase level to set max time any one query can run e.g. no query over n hours. This would help kill such queries.
    Also is it possible to cap individual queries to say one query can never use more than n% of cpu, ram available?
    ThanksIf you have Enterprise Edition licences, this is straightforward with the Resource Manager: set a threshold for MAX_EST_EXEC_TIME and all queries that might exceed this will be blocked. You also have CPU limits available.
    John Watson
    Oracle Certified Master DBA
    http://skillbuilders.com

  • Error 1603: Need some help with this one

    When installing iTunes I first get an error box saying
    "Error 1406: Could not write value to key \Software\classes\.cdda\OpenWithList\iTunes.exe. Verify that you have sufficient access to that key, or contact your support personnel."
    The second one (after I click on Ignore on the last box) I get it this one:
    "Error: -1603 Fatal error during installation.
    Consult Windows Installer Help (Msi.chm) or MSDN for more information"
    Strange thing is that I do have full access to my computer (or atleast in all other cases I have had since I am the only one with an account on it).
    I have done my best in trying to solve it myself but I'm running out of ideas. I have downloaded latest versions from the website and tried installing Quicktime separately. I have also tried removing Quicktime using add/or remove programs though I just I didn't dare to take full removal because it said something about system files.
    Anyway I really need some help with this, anyone got any ideas?
    Greets,
    Sixten
      Windows XP Pro  

    Do you know how to count backwards? Do you know how to construct a loop? Do you know what an autodecrementor is? Do you know how to use String length? Do you know Java arrays start with index 0 and run to length-1? Do you know you use length on arrays too? Do you know what System.out.println does?
    Show us what you have, there isn't anything here that isn't easily done the same as it would be on paper.

  • Need query help regarding employee retirement age.

    Need query to find employee retirement age 2years in advance.

    You can use per_all_people_f table.
    something like this :-
    SELECT PAPF.employee_number,
    PAPF.date_of_birth,
    (MONTHS_BETWEEN(SYSDATE,PAPF.date_of_birth) / 12)+2 RETIREMENT_AGE_FIGURE
    FROM per_all_people_f PAPF
    WHERE TRUNC (SYSDATE) BETWEEN PAPF.effective_Start_date AND PAPF.effective_end_date
    AND (MONTHS_BETWEEN(SYSDATE,date_of_birth) / 12)+2 >=65 /* ASSUMING 65 IS RETIREMENT AGE HERE*/
    In case if you only want to pick Employee data then use below sample query and modify according to your requirement :-
    SELECT PAPF.employee_number,
    PAPF.date_of_birth,
    ((MONTHS_BETWEEN(SYSDATE,PAPF.date_of_birth) / 12)+2) RETIREMENT_AGE_FIGURE,
    PPT.system_person_type,
    PPT.user_person_type
    FROM per_all_people_f PAPF,
    per_person_types PPT,
    per_person_type_usages_f PPTUF
    WHERE TRUNC (SYSDATE) BETWEEN PAPF.effective_Start_date AND PAPF.effective_end_date
    AND ((MONTHS_BETWEEN(SYSDATE,date_of_birth) / 12)+2) >=65
    AND PPTUF.person_id = PAPF.person_id
    AND PPT.person_type_id = PPTUF.person_type_id
    AND PPT.system_person_type = 'EMP'
    AND TRUNC (SYSDATE) BETWEEN PPTUF.effective_Start_date AND PPTUF.effective_end_date
    Edited by: VISHAL DANGI on Jul 8, 2012 10:30 PM

  • Hi query in pricing any one please help needed

    our project requirement
    EX: if I am dealing with all the customers for material 1, material2 material3.......up to 50 materials. If I would like to check minimum order quantity only for few materials (let us say material1 minimum 5 quantity and material 2 minimum 5 quantity and <b>material1 +material2 combines 10 quantity</b> is also Ok) and if any customer not buying in this category automatically $10 fee(surcharge?) has to apply for this order.

    Hi sai,
      Pls check out for condition type kp00 to kp04.I am not sure whcin ctype it is.It for calculating mixed pallet surcharge .Where a surcharge will be levid on the customer .If he doesnt order for the goods in full pallet.ie if pallet can hold 100 qty and if u order only 50 pcs.then u can get a surcharge from the customer.
      I think by going thro this conditions and making slight modificationss u can  meet u'r requirement.Details about these conditions are avbl in SAP library under special pricing conditions.
    I am not confident whether its right.Guru's pls point out if i am wrong.
    Regards,
    K.Vivek

  • Query help. Any work around?

    Hi To all,
    Help me on this query.
    Table1 : seating_layout
    Columns(1) : Seat_no values 50 records i.e.. 1,2,3..50
    Ex. Data :
    1
    2
    3.. upto 50, i.e total 50 records
    Table : Quotas
    Columns(2) : seat_no_from, seat_no_to
    Ex. data :
    1 5
    8 13
    I need a query which gives values in a DYNAMIC RECORD GROUP in FORMS6i as below
    1,2,3,4,5,8,9,10,11,12,13. i.e. total 11 records.
    Im using Version Oracle 8i, Forms 6i. is there any work around to get the result.
    Thanks in advance.

    select map_name,data_entity_name
    from ALL_IV_XFORM_MAP_COMPONENTS
    where operator_type = 'Table';
    or
    /* SOURCE - TARGET */
    http://www.nicholasgoodman.com/bt/blog/2005/04/01/owb-sources-and-targets-sql/
    select
    distinct 'TARGET',
    comp.map_name,
    comp.data_entity_name,
    comp.operator_type
    from
    all_iv_xform_map_components comp,
    all_iv_xform_map_parameters param
    where
    lower(operator_type)
    in ('table', 'view', 'dimension', 'cube')
    and param.map_component_id = comp.map_component_id
    and param.source_parameter_id is not null
    UNION
    select
    distinct 'SOURCE',
    t1.c1,
    t1.c2,
    t1.c3
    from
    (select
    comp.map_name c1,
    comp.data_entity_name c2,
    comp.operator_type c3,
    max(param.source_parameter_id) c4
    from
    all_iv_xform_map_components comp,
    all_iv_xform_map_parameters param
    where
    lower(operator_type) in
    ('table', 'view', 'dimension', 'cube')
    and param.map_component_id = comp.map_component_id
    group by
    comp.map_name, comp.data_entity_name, comp.operator_type) t1
    where t1.c4 is null
    order by 2,1

  • Search Query Help – more than one word

    I have been struggling with this for weeks.  I used Dreamweaver to set up a lot of this and I think it is hindering me as I make changes to the code.
    I have a search interface that takes the input from a user (in the form of text) – searches though the db to match words – then return the results based on how many times the input is located in the db.
    I have this working very good for a single word input.  If you search for one word only – it works great.  But, if you try to input two words together – it returns no results.
    I have tried several different things to get this to work – like exploding the input then searching the db for each word in order.  The problems I get, I think, is that this conflicts with the code Dreamweaver wrote – I think where the code requests the value string.  But, each time I think I find a fix for one error – it creates several others – not just in the php code above the header – but in the php code in the body when I try to retrieve the results.
    It seems that I am just going around in circles.  But, there has to be simple way to search for more than one word in the db – count the matches – add the matches from each search together – then return the results ordered by the largest number of matches.
    I have even tried using a foreach statement – but received errors that I have never seen before.  Then after researching and trying to fix those errors – just received more and more errors.
    Please help.  If it cannot be done given the code I have – then please point me in the right direction to rewrite the code.
    Code is attached.

    Based on what you explained as your requirements, it is very easy. I'll just speak in psuedo-code.  You will need to parse the input into seperate words. If there can be an unknown number of words you can store those in a string array.
    Then just use the array to build your where clause using the IN predicate or using the = and OR operators.
    Select count(*), keyword
    where keyword in (term[0], term[1], etc)
    group by keyword
    order by count(*) desc
    If this is not what you meant, then you will need to explain your requirements in more detail. As you have discovered, once your requirements exceep the capabilities of DW's behaviors, you will need to become very familar with sql and your server side scripting language. If you don't understand what the DW code is doing (as evidenced by your comments in the attachment), then you really are not ready to start modifying it.

  • Pls help me any one, ADF Faces EO,VO creation in mutiple table..

    problem here:
    table1
    field1 (pk)
    field2 NAME
    table2
    field1 (pk)
    field2 (fk for table1)
    field3 NAME
    table3
    field1 (pk)
    field2 (fk for table2)
    field3 NAME
    Here each table having separate panel tabbed, i want to show table1 of
    field2 in third panel tabbed(screen). How i can create EO,VO to show
    with success.
    When i'm showing the table1 of field2, is not require to do a DML operations.
    like this my third screen's adf table
    field2(table1) field2(table3) field3(table3)
    (showing for
    user identify)
    Urgent Requirement pls help me.
    In case of any query please free to mail @ [email protected]
    Thanks & Regards,
    Rengaraj
    Edited by: user11129216 on May 4, 2009 7:21 AM

    Like Frank, I'm not 100% sure I'm understanding your requirement, but here are some observations.
    Your three tables look like master/detail/detail, let's say it was Regions->Countries->Locations
    So, you would build a RegionsView VO to show the Regions information.
    You would build a CountriesView VO to show the Countries information.
    You would build a LocationsView VO to show the Locations information.
    Then you would create a view link between RegionsView and CountriesView to coordinate that master/detail relationship.
    Then you would create a view link between CountriesView and LocationsView to coordinate that master/detail relationship.
    All of the above will be created automatically for you if you have foreign keys defined in the database when you use the Create Business Components from Tables wizard. (including the underlying entity objects for your database tables, associations that reflect your foreign key relationships).
    If you want LocationsView to show information from its parent, you can include the Country EO as an entity usage in the LocationsView and include the attributes from country that you want to appear in that (join) query. You can repeat to also add the Region EO as an entity usage to join all three.
    Then, you would drop RegionsView from the data control palette onto tab1, CountriesView onto tab2, and LocationsView onto tab 3.

  • Need query help... Urgent Plz

    hi,
    i have the table like this.
    cityid ----- productcode
    1 ------ 100
    1 ------ 100
    2 ------ 101
    2 ------ 100
    2 ------ 102
    2 ------ 102
    2 ------ 102
    3 ------ 103
    3 ------ 104
    3 ------ 102
    i have 20 lacks records in the table.
    i want to retrive top 20 city based on the cityid count descending order,
    and top 1 product code of these cities based in the product count descending order.
    i need the query for this.
    Thanks,
    S.Ashokkumar.

    Hi,
    can try this,
    --not tested
    SELECT COUNT(*) , citiid, productcode
    FROM table1 t1
    having max(productcode) = (SELECT max(productcode) from table1 t2 where t1.citiid= t2.citiid)
    GROUP BY citiid, productcode
    order by citiid DESC
    May be this link will help.
    http://forums.oracle.com/forums/ann.jspa?annID=719
    thanks

Maybe you are looking for

  • SAP Netweaver 7.02 Delete Database Table log

    Hi, I'm having a problem with a database table(transparent table) that was deleted on an SAP Netweaver 7.02 system. Are there any logs where I can see who deleted the table? Thanks, Sergiu

  • Application positioning content incorrectly

    I am having an issue with the way ApplicationLayout is positioning content in Flex 3.2, I have a single container inside the Application tag and it is set to 100% and the scrollbar is on at the Application level. When I step through ApplicationLayout

  • Exit window when cklicking the exit button of the window

    Hello, my form exists of some canvases and windows. At the moment I have in every window a button to hide the active window. But I want to exit or hide the window by cklicking on the 'X' above in every canvas or window. How can I do that?

  • Cannot run Firefox

    I cannot get Firefox to start at all. I have tried opening the browser from the short cut on the task bar, from Start -> programs, by double clicking the desktop shortcut icon but none of these open Firefox. I have rebooted the computer but the probl

  • Scrolling down doesn't stick, keeps jumping back up

    Anyone else having this problem and know a solution?: when I scroll down an event's pictures a little bit, after just a second or two the window all by itself scrolls back to some arbitrary point higher up in the event, it just won't stay put so I ca