How I make these data by writing the request right?

Dear Exparts
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
"CORE     10.2.0.3.0     Production"
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
I have a table name TB and column A and B with the following data.
A       B
10     02-AUG-2012
10     04-AUG-2012
10     01-SEP-2012
10     10-AUG-2012
11     04-AUG-2012
11     01-SEP-2012
11     01-AUG-2012
10     12-AUG-2012
10     15-JUL-2012
I need data as
A                      B
10            10-AUG-2012
10            12-AUG-2012
10            01-SEP-2012
11            01-SEP-2012
How to get this data?
We need group column a. column B then divided the count_value by 2 and trunc base on the result will put and it come. the data is the maximum data.
Like when we have group a result will be
A            B
10           3
11           1
based on the above result as my desire outpul will come...

Here is the script
CREATE TABLE TB
  (
    "A" VARCHAR2(20 BYTE),
    "B" DATE
  )

Insert into TB (A,B) values ('10',to_date('02-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('04-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('01-SEP-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('10-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('11',to_date('04-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('11',to_date('01-SEP-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('11',to_date('01-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('12-AUG-2012','DD-MON-RRRR'));
Insert into TB (A,B) values ('10',to_date('15-JUL-2012','DD-MON-RRRR'));
Thanks in advance...
Ask2Learn

Published by: ask learning 1 Sep 2012 07:55

Published by: ask learning 1 Sep 2012 08:38 (CHANGE DATA TYPE) SORRY

Asked to know wrote:
I need a basic select statement as I need for reports...

your query is not working, reports...

Thank you...

Select base means? I don't have it. What did you mean?

are you ready to be confused WITH the CLAUSE?

select a,b
from (select a.*,row_number() over(order by b desc) rn from tb a)
where rn<(select max(cnt)
          from (select round(count(*) over(order by b desc)/2) cnt
          from tb))
order by a;

Tags: Database

Similar Questions

  • How to make uneditable Date field in ADF

    Hello

    I use Jdev 11.1.1.7.1.

    In the fragment, I added the DATE of the ENTRY component. How to make uneditable date field. He should just take the input value of the grille.

    Kindly advice me.

    Thank you

    Swathi

    Your date. MinValue must be like this:

    
                
                
                  
              
    
  • How many gigabytes of data storage has the new Apple Watch series 2 and how many GB are free for music?

    How many gigabytes of data storage has the new Apple Watch series 2 and how many GB are free for music?

    Hello

    Apple has not yet announced the capacity of storage or the music of Apple Watch series 2 storage limit.

  • How to make transparent cluster keeping only the elements inside the visible cluster?

    Hello

    Can anyone suggest me how to make transparent cluster keeping only the elements inside the cluster visible in the front panel.

    Thanks in advance,

    Vinciane

    As I said, use the space bar for what is paint. This works. Trust me.

    PS You cannot link to pictures stored on your hard drive. We don't see them. You must add them as attachments and then submit the post they get uploaded to the servers of NOR.

  • I get my email on two computers. How to make a computer out of the loop?

    I get my email on two computers. How to make a computer out of the loop without jeopardizing my Comcast email account?

    Using Outlook Express? Go to: tools | Accounts and delete the account. If you think you can it in the future, go to the properties of the account, and under the general tab, simply uncheck: include this account when receiving or synchronization.

    If you are interested, you can receive messages at a time without losing them on one.

    On both machines:

    Tools | Accounts | Mail | Properties | Advanced - Check: leave a copy of messages on the server.

    On a single computer only, make sure to delete messages after X days to satisfy your allocated space that you get from your server.

  • How to make 'Save to Desktop' save the default value instead of 'This PC'?

    How to make 'Save to Desktop' save the default value instead of 'This PC'?

    Windows 10, I guess?

  • In CC Dramweaver Adobe how to make my Web page fill the entire window?

    In Adobe Dreamweaver CC how to make my Web page fill the entire window?

    A width of 100% CSS.


    Body {width: 100 %}}

    Nancy O.

  • How to add a data center on the virtual center via VI client server?

    How to add a data center on the virtual center via VI client server?

    I formatted ESX server & ESX Server Update installed keeping the data center on the storage (of many desktop computers)

    Now I have fresh installed a new server of virtual & added the ESX Server, but I'm unable to reattach existing data centers on storage.

    What will be the way to import of existing data on server Center virtual center?

    Help, please...

    Is ' VMware-VMimporter - 2.0.0 - 30557 "is the software through which I can solve my problem?

    You need to browse each data store, go to the folder of the virtual machine, right-click on the *.vmx file and add it to your inventory.

    Andrea

    * If you found this device or any other answer useful please consider awarding points for correct or helpful answers

  • How to find these different namespaces in the schema?

    Hello

    I heard that this schema contains different namespaces. How to find these different namespaces in the schema?

    I checked with this, but it is throwing "table or view does not exist.

    Select the namespace of v$ librarycache.


    Thank you
    Praveen

    Are you referring to this? From the reference manual of the SQL language under the schema object names and qualifiers

    7. part of a namespace, no two objects can have the same name.
    The following schema objects share a namespace:
    Tables
    Display
    Sequences
    Private synonyms
    Autonomous procedures
    Autonomous stored functions
    Packages
    Materialized views
    User-defined types

    Each of the following schema objects has its own namespace:
    Index
    Constraints
    Clusters
    Database triggers
    Private database links
    Dimensions

    Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name. However, the tables and indexes are in different namespaces. Therefore, a table and an index in the same schema may have the same name.

    Each schema in the database has its own namespaces for objects that it contains. This means, for example, two tables in different schemas are in different namespaces and can have the same name.

    Each of the following schema objects also have its own namespace:
    User roles
    Public synonyms
    Links to public database
    Storage spaces
    Profiles of school boards
    The files (PFILEs) settings and server settings (SPFILEs) files

    Because objects in these namespaces do not appear in the drawings, these namespaces cover the entire base.

    That's why you can do:

    SQL> create table t (id number, descr varchar2(10));
    
    Table created.
    
    SQL> alter table t add constraint t check (mod(id,2) = 0);
    
    Table altered.
    
    SQL> create index t on t(id);
    
    Index created.
    
    SQL> create trigger t
      2  before update on t
      3  begin
      4     dbms_output.put_line('T Trigger');
      5  end;
      6  /
    
    Trigger created.
    

    but not:

    SQL> create view t as select * from t;
    create view t as select * from t
                *
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    

    or

    SQL> create procedure t
      2  begin
      3     null;
      4  end;
      5  /
    create procedure t
    *
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    

    John

  • How to make a web page to the size of browsers?

    How to make a web page to the size of browsers?

    Try to download the pdf file and the example in this tutorial files, which explain how to do this.

    http://www.Adobe.com/devnet/Dreamweaver/articles/bk_dwcs4_mastering_css.html

    PZ

  • How can I remove my name from the top right of the screen. I have a 2015 13 "MacBook Pro running 10.11.4

    How can I remove my name from the top right of the screen. I have a 2015 13 "MacBook Pro running 10.11.4

    At the top right of the menu bar shows the current user who is logged in and allows quick change of user accounts.

    You can disable the display of menu bar in system preferences > users and groups. Or order just drag it out of the bar.

  • How to add my link (folder) to the side RIGHT of the Start Menu?

    How to add my link (folder) to the side RIGHT of the Start Menu? I mean under my documents my music.

    Do I need a registry change or easy way?

    See my post here.

    Replace "Set Program Access and Defaults" Start Menu XP with trash:
    http://groups.Google.com/group/Microsoft.public.WindowsXP.customize/browse_thread/thread/1479ca45f5598b84/91bef4c26cd81c6b?q=replace+%7B2559A1F7-21D7-11D4-BDAF-00C04F60B9F0%7d
    Ramesh Srinivasan, Microsoft MVP [Windows Desktop Experience]

  • The data specified in the request is invalid. The value of the field id package is not a MultipleLiteral, but the field is defined as MultiValued

    We have a property in a component software which is an array. the value is [""]

    In the blueprint I am sitting a value property ['vim', 'emacs'] defalult

    When I ask this plan and change the values of foo, bar, I get this error

    The data specified in the request is invalid. The value of the field id package is not a MultipleLiteral, but the field is defined as MultiValued

    someone knows why this happens?

    I'm runnign vra7.0.1

    Strangely, it works if

    Overridable is set to NO

  • How to make readable text fields after the filling of data

    Hello

    Once we get the data in the message text entry fields, we have a few only readable areas.
    I tried to make these fields as readable as follows:

    In the property inspector Table RN, I changed the functional property of 'Read' only True value
    But in the custom OAF page, text box is missing for this field.
    Could someone help me how to do this?

    Thanks in advance
    Nanoo

    Hi Nanoo

    Here's the modified code, you can use

    public void setReadonly()
    {
    XXIDVOImpl vo=getXXVO1();
    Row poRow = vo.first();
    for(int i=0;i
    

    I hope that helps!

    Thank you
    AJ

  • How to get these substrings based on the input string

    Hi friends
    I want the substring entered the string
    the chain is something like this: 1234,3653,7684,3254,8777,987,234
    now, I want to
    the substrings between commas

    can someone help me with this pls

    in the first substring I need 1234
    in the second, I need 3653...
    so on until the end...
    regardless of the channel is to the last

    pls help

    Hello

    You can do something like this:

    SELECT     txt
    ,     REGEXP_SUBSTR (txt, '[^,]+', 1, 1)     AS part_1
    ,     REGEXP_SUBSTR (txt, '[^,]+', 1, 2)     AS part_2
    ,     REGEXP_SUBSTR (txt, '[^,]+', 1, 3)     AS part_3
    --     ...
    FROM     table_x
    ;
    

    If there are less than n parts, then the technique above will not raise an error; It will just return null for part_n.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
    Explain how you get these results from these data.
    What you want if the entry is like this.
    {code}
    "foo, bar".
    {code}
    ? You want to treat this as 2 pieces ('bar' is the 2nd) or a 3 s (the 2nd is NULL, and 'bar' is the 3rd)? Include examples in your sample data and results.
    Always tell what version of Oracle you are using.

Maybe you are looking for

  • Why isn't the iPod 5th generation 10 supported iOS?

    I was happy that iOS 10 was compatible with the 5th gen iPod while it was not now, I'm a consultant on the weather to buy the new iPhone or stay with my iPod for everyday use

  • How can I customize receipts to return with a message?

    We go far and I want to send an automatic reply with the message "received messages", which should go to my correspondent, because I don't want my family to have to do this every time. Is this possible?

  • iMovie is not free?

    Hello. I own a macbook pro mid 2014 OS X El Capitan 10.11.3 and recently, I started to get into video editing and wanted to use iMovie, and it seems that I am not and when I tried to download it from the App Store is not free and so far I can say I s

  • Does the Acer Aspire 4530 TV output support?

    My father has an old Acer Aspire 4530. I am trying to determine if it has tv out capability so we can connect to its new TV with a cable composite VGA adapter. It has a VGA port, and it's really... I think that its come to Aspire with Vista (not sure

  • emails not sent to microsoft outlook

    I have not received emails on outlook since July, it's extremely frustrating. I can access my hotmail via the internet, however, prefer to use microsoft outlook. I also began to receive a box requires me to enter my network password.  I walked severa