To find unique date... Good question

Consider the following tables in your schema.
1. TOPTEN_SHIPS
2. TOPTEN_BATTLES
A typical SHIPS record would be:
(1,'New Jersey', 1943, 'USA', 9, 16, 46000)
Which means that the battleship New Jersey with id 1 was launched in 1943; it belonged to the USA, carried 9 guns of size 16-inch (bore, or inside diameter of the barrel), and weighted (displaced, in nautical terms) 46,000 tons.
A typical record for BATTLES is:
(1, 'North Atlantic', 1,'sunk')
That is, ship with id 1 (i.e. New Jersey) was ‘sunk’ in the battle (with id 1) of the North Atlantic.
Write the following queries:
(a) Grade: Medium
Recommended Time to be spent on the question: 20 min
List all the pairs of countries that fought each other in battles. List each pair only once, and list them with the country that comes first in alphabetical order first. Let’s say the country names are C1 and C2. C1 should appear first over C2 based on alphabetical order. Additionally C1 should only start with alphabet A.
The output should be ordered by country1, country2.
TOPTEN_SHIPS          
TS_SHIP_ID     NOT NULL     NUMBER(10)
TS_SHIP_NAME          VARCHAR2(100)
TS_YEAR_LAUNCHED          DATE
TS_COUNTRY          VARCHAR2(100)
TS_NUM_GUNS          NUMBER(10)
TS_GUN_SIZE          NUMBER(10,2)
TS_DISPLACEMENT          NUMBER(10)
TOPTEN_BATTLES          
TB_BATTLE_ID     NOT NULL     NUMBER(10)
TB_BATTLE_NAME          VARCHAR2(100)
TB_SHIP_ID     NOT NULL     NUMBER(10)
TB_RESULT          VARCHAR2(50)

if you want a generic method you can do something like this...
WITH t AS
  ( SELECT 'A' c1,'B' c2,'C' c3 FROM dual
UNION ALL
   SELECT 'A' c1,'B' c2,'D' c3 FROM dual
UNION ALL
   SELECT 'B' c1,'C' c2,'A' c3 FROM dual
UNION ALL
   SELECT 'C' c1,'A' c2,'B' c3 FROM dual
UNION ALL
   SELECT 'D' c1,'B' c2,'A' c3 FROM dual
SELECT DISTINCT ltrim(sys_connect_by_path(cvalue,','),',') finval
   FROM
  (SELECT c1           ,
    c2                 ,
    c3                 ,
    column_value cvalue,
    row_number() over (partition BY c1,c2,c3 order by column_value ) rnum
     FROM t,
    TABLE(sys.odcivarchar2list(c1,c2,c3))
  WHERE CONNECT_BY_ISLEAF =1
  CONNECT BY prior rnum   =rnum-1
AND prior c1              =c1
AND prior c2              =c2
AND prior c3              =c3
  START WITH rnum         =1But still if you want unique out of 4 columns then you need to change the above one accordingly.
Ravi Kumar

Similar Messages

  • The DATA CAP MEGA THREAD....post data cap questions or comments here.

    In the interest of keeping things orderly....This is the DATA CAP MEGA THREAD....post data cap questions or comments here.
    Please keep it civil.
    Comcast is testing usage plans (AKA "data caps") in certain markets.
    The markets that are currently testing usage plans are:
    Nashville, Tennessee market: 300 GB per month and additional gigabytes in increments/blocks ( e.g., $10.00 per 50 GB ). 
    Tucson, Arizona market: Economy Plus through Performance tiers receive 300 GB. Those customers subscribed to the Blast! Internet tier receive 350 GB; Extreme 50 customers receive 450 GB; Extreme 105 customers receive 600 GB. Additional gigabytes in increments/blocks of 50 GB for $10.00 each in the event the customer exceeds their included data amount. 
    Huntsville and Mobile, Alabama; Atlanta, Augusta and Savannah, Georgia; Central Kentucky; Maine; Jackson, Mississippi; Knoxville and Memphis, Tennessee and Charleston, South Carolina: 300 GB per month and additional gigabytes in increments/blocks ( e.g., $10.00 per 50 GB ) Economy Plus customers have the option of enrolling in the Flexible-Data plan.
    Fresno, California, Economy Plus customers also have the option of enrolling in the Flexible-Data plan.
    - If you live outside of these markets you ARE NOT currently subject to a data plan.
    - Comcast DOES NOT THROTTLE your speed if you exceed your usage limits.
    - You can check out the Data Usage Plan FAQ for more information.
     

    I just got a call today that I reached my 300GB limit for the month.  I called and got a pretty rude response from the security and data usage department.  The guy told me in so many words that if I do not like or agree with the policy that I should feel free to find another service provider.!!! I tried to explain that we watch Netflix and XFinity on-demand alot and I was told that that can not be anywhere close to the data usage. I checked my router and watching a "super HD, dolby 5.1" TV show on Netflix will average about 5-6 GB per hour (1.6MB/s) ... sp this means that I can only watch no more than 1-2 Super HD TV shows a day via Netflix before I run out of my data usage.    This seems a bit redicilous doesn't it? Maybe the TV ads about the higher speed than the competition should be accompanied with "as long as you don't use it too often"   Not a good experience ... 

  • Unable to find security data

    Hello,
    I am trying a scenario file--> xi ---> RFC , does anybody know what this message means. The problem appear when I send a flat file to XI.  My question is, do I need to make some extra settings ?
    This is the error am getting.
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Technical Routing
      -->
    - <SAP:ErrorHeader xmlns:SAP="http://sap.com/exchange/MessageFormat">
      <SAP:Context />
      <SAP:Code p1="Intromoto_bus,zempiface/http://empinfo.com" p2="sap_bus,ZHRONBOARD_ACCEPT/urn:sap-com:document:sap:rfc:functions" p3="" p4="">PHYROU.UNDEFINED_SECURITY</SAP:Code>
      <SAP:Text language="EN">Technical routing: Unable to find security data for sender Intromoto_bus,zempiface/http://empinfo.com for receiver sap_bus,ZHRONBOARD_ACCEPT/urn:sap-com:document:sap:rfc:functions</SAP:Text>
      </SAP:ErrorHeader>
    Rgds,
    Ram Sri

    Hi,
    but then, the error message is very concise. The security object in the integration directory with the key:
    Send:
    Intromoto_bus
    zempiface
    http://empinfo.com
    Rec:
    sap_bus
    ZHRONBOARD_ACCEPT
    urn:sap-com:document:sap:rfc:functions
    is missing. You need to create it in the directory.
    Regards,
    Hermann

  • Unable to find security data for sender

    Hello, does anybody know what this message means. The problem appear when I send an Idoc to XI. Other interfaces (Master data) are working properly. My question is, do I need to make some extra settings for the transactional data interfaces (SHPMNT)?
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Technical Routing
      -->
    - <SAP:ErrorHeader xmlns:SAP="http://sap.com/exchange/MessageFormat">
      <SAP:Context />
      <SAP:Code p1="sapdev222,SHPMNT.SHPMNT05/urn:sap-com:document:sap:idoc:messages" p2="VENDORMASTER_WOLTERKLUWER_ERP_BE,IDZ0001_DeliveryReplicate_IB/http://wolterskluwer.com/xi/midas_deliveries" p3="" p4="">PHYROU.UNDEFINED_SECURITY</SAP:Code>
      <SAP:Text language="EN">Technical routing: Unable to find security data for sender sapdev222,SHPMNT.SHPMNT05/urn:sap-com:document:sap:idoc:messages for receiver VENDORMASTER_WOLTERKLUWER_ERP_BE,IDZ0001_DeliveryReplicate_IB/http://wolterskluwer.com/xi/midas_deliveries</SAP:Text>
      </SAP:ErrorHeader>
    regards
    Ernesto Duran

    HI,
    i am also getting the same error in my scenario. Could u plz inform me what is the solution?
    Rgds,
    Ram Sri

  • Can't find my data file to back up, so I can uninstall and reinstall the software. (Windows, Vista & Palm version 6.0.1)

    I can't find my data file, in order to back it up.  After going to Documents - Palm One, the only thing that looks like a user name is a file with no data.  Somewhere there has to be another file with all my data, since data is available when I open the Palm One software on my computer.  After backing it up, I want to uninstall and reinstall the Palm One software.  I'm hoping this resolves my inabilty hot sync.  Thanks!  Lauraflavin.
    Post relates to: Tungsten T5

    If you're using XP, your data is here:
    C:\Program Files\Palm (or PalmOne)\ your Hotsync Name abbreviated \
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • How to find the data loaded from r/3 to bw

    hi
    how to find the data loaded from r/3 to bw is correct . i am not able to find which feild in the query is connected to which feild in the r/3 . where i am geting the data from r/3 . is there any process to find which feild  and table the data is comming from . plz help
    thanks in advance to u all

    Hi Veda ... the mapping between R/3 fields and BW InfoObjects should take place in Transfer Rules. Other transformation could take place in Update Rule.
    So you could proceed this way: look at InfoProvider Data Model and see if the Query does perform any calculation (even with Virtual keyfigures / chars). Than go back to Update Rules and search for other calculation / transformation. At least there are Tranfer Rule and eventually DataSource / Extraction Enhancements.
    As you can easily get there are many points where you have to look for ... it's a quite complex work but very usefull.
    Once you will have identified all mappings / transfromation see if BW data matchs R/3 (considering calculations ...)
    Good job
    GFV

  • To find the date type fields in the row and validate those date fields

    TYPES : BEGIN OF TY_MARA,
              MATNR TYPE MARA-MATNR,
              ERSDA TYPE MARA-ERSDA,
              ERNAM TYPE MARA-ERNAM,
              LAEDA TYPE MARA-LAEDA,
              MTART TYPE MARA-MTART,
            END OF TY_MARA.
    DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
          it_mara1 TYPE STANDARD TABLE OF ty_mara,
           wa_mara TYPE ty_mara.
    loop at it_mara into wa_mara.
      describe field wa_mara-ersda type c_data.
    if c_data eq 'D'.
      CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
        EXPORTING
          date                            = wa_mara-ersda
       EXCEPTIONS
         PLAUSIBILITY_CHECK_FAILED       = 1
         OTHERS                          = 2
      IF sy-subrc eq 0.
    wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
        else.
            wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
      ENDIF.
      endif.
      endloop.
    This issue regarding how to find the date type fields in the row and validate those date fields.If its not a valid date ,i have to assign initial value to that.
    I've tried that for single field using describe field.Please help me do that for all fields.

    Hi Sam,
     I believe we had discussed the same issue in the below thread. Can you please refer the below one?
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d93e16ff-c123-4b36-b60b-60ccd34f6ca7/calculate-time-differences-in-infopath?forum=sharepointcustomizationprevious
    If it's not helping you please let us know
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • How to find the date my iPhone 4s was manufactured

    Hi, Please can anyone tell me how to find the date my iPhone 4s 64gb was manufactured. I have the serial and i-m-e numbers. For some reason my Insurance company want to know, all I wanted to do was add the phone to my all risks policy. Thanks in advance for any advice.

    That's all you will get, there is no way to know the manufactured date only the warranty status from date of original sale and it is most unlikely your warranty is still "good" on an iPhone 4

  • Why the delivery date is the same date as 'transptn plan date" & loading date' & ' good issue' & GR end date'

    Hi Experts,
    why the delivery date is the same date as ‘transptn plan date” & loading date’ & ‘ good issue’ & GR end date’.
    in shipping tab i can see Planned Deliv. Time  170 Days ... wat could be the reason.
    Many Thanks:
    Raj Kashyap

    Hi Jurgen,,
    Thanks for quick reply!!
    But i didnot find any things like that .. what could be the customizing .. and we are using GATP from APO side.
    \Raj Kashyap

  • How can I find a data base table containing a GUID, which is result of the macro's execution?

    Hello,
    please help me to understand how the macros work. I am facing database inconsistency. The CRM-system retrieves a GUID of an opportunity’s item and checks its existence. However, this GUID (here it is es_info-ref_object) does not exist. As result, an exception is triggered.
    I am trying to figure out which data base table is responsible for the inconsistent data. Instead of SELECT statement, I see in the debugger that a macro retrieves the “guilty” entry .
    macro_execute macro_msg_data_read_rea.
    My Question: How can I find a data base table containing a GUID, which is result of the macro’s execution?
    Thanks a lot
    Andrej

    When you save a PDF out of Distiller it doesn't just have different options, it's an entirely different program. It doesn't do things the same way, so it can't have the same options. Saving from Distiller is in many ways better, expecially in that transparency isn't flattened.
    What specific options are you looking for?

  • FINDER: File Date & Time Slow to Update

    In finder windows my date and time is slow to "update" when I've changed a file. Viewing by "Date Modified" is worthless sometimes. I change & save a file, view in finder and the date & time has not updated. Update times vary from immediate to minutes...
    Surely this isn't typical? The systme can't handle getting file date&time updated?
    10.4.7 on Dual 1Gz machine.
    comments?

    Hi, Greg.
    I've seen this happen from time to time myself. In my case it has been very rare and I've been unable to pin down a cause. It appears to be a bit of a glitch in Finder. It's usually seen with server-mounted volumes even though it was supposedly fixed in Tiger after being a regular issue with shared volumes in Panther.
    Some ideas:
    • Temporarily switching the View from say List to Icon and Back often corrects this.
    • You might want to take a look at Nudge.
    • If it's happening at high frequency, purging your Finder preferences may help. See my "Finder Issues? How to delete its preferences" FAQ.
    • You may want to try Path Finder, an alternative Finder. You can use Finder and Path Finder simultaneously.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X
    Note: The information provided in the link(s) above is freely available. However, because I own The X Lab™, a commercial Web site to which some of these links point, the Apple Discussions Terms of Use require I include the following disclosure statement with this post:
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • Alternative to find unique records with 60 character in selection string.

    Hi,
    We have to find out the values from the Infoobject. When we try to display data from an master object, the maximum length of selection it accepts 45 characters only but we need to input data around 60 characters in selection.
    Thing we tried:
    1. Selecting complete data without any condition but it did not work due to large volume of data.
    2. We tried to extract data from RSA3 but it did not work due to large volume of data.
    Please suggest me alternative to find unique records with 60 character in selection string.
    Regards,
    Himanshu Panchal.

    This sounds a bit strange. Are you perhaps mistakenly storing text data incorrectly as the primary key of the master data? I can't think of any actual data that is that length to ensure usinqueness - even GUIDs are maximum 32 characters - but GUIDs don't count as actual "readable" data although you do need to be able to select it from time to time. Perhaps you have a super secure password hash or something like it ?
    Also are you expecting to have a unique single record returned by your selection? To do this would in general REQUIRE that ALL the data is read because master data is not stored in the DB sorted by the data itself, but stored instead sorted by the it's SID.
    When you say you are selecting data from master data, which master data tables are you using? I have been able to select data from very large MD table (15 million unique records) using SE16 with no problems. Just enter the table name, and before you execute just count the number of records - it helps to know what you want to end up with.
    Have you tried using wild cards (the *) to preselect a smaller number of records : * a bit of your 60 character string *
    If you are trying to select from a non-key field you will encounter performance issues, but you can still use the wildcards, and get a result.
    Don't use RSA3 it was designed to make selections and group them into datapackets. It's not the same as selecting directly on the table in SE11 or SE16

  • How to find creation date of a cron job in RHEL 5

    We have instances having RHEL 5.10 in our setup. I wanted to know how to find the creation date of a cron job in RHEL 5. I was investigating a cron job, hence the query to know the creation date of a cron job.
    I hope my question is clear.
    Requesting a reply to my query.
    Regards

    Sorry to have upset you, but I cannot understand your accusation. Could you please explain where you see aggression in my problem evaluation or where I implied "how dare you"?
    I also provided an explanation why the cronfile in /var/spool/cron is not helpful. If I'm wrong, by all means, please let me and anyone else know.
    If no filesystem is specified I assume the default file system, which under OL 6 is ext4 and xfs under OL 7. Furthermore I was assuming ext3 due to other questions the OP has been asking in a similar context, which you may have not seen. For example: How to find creation date of a file in RHEL 5

  • How to find Installation Date for each SQL installation

    Dear All,
    I need a basic info. How to find installation date of each SQL instance (My environment running with multiple standalone/cluster instances)?
    So, I need a query to find installation date easily (I don't want to check it in registry by manual). Thanks in advance...

    Hi Balmukund
    This is the same answer that (1) Prashanth posted
    from the start, letter on (2) Stan posted
    this again with the same link, and now for the third time, (3) you posted it with the same link :-)
    * This answer is correct for specific instance.
    The OP asked a solution for several instances. Therefore he should execute this on each instance. As I mentioned he can do it dynamically on all instances, for example using powershell (basic logic is, first find all instances and than post this query in a
    loop).
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]
    Then your answer is correct :)
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Require query for unique data?

    hi,
    i have a partitioned table which has some data.
    i want to get unique data for a combination of columns.
    i want to get unique data for the combination of cid, lid in the table cdi_post_curr...
    if i use select distinct cid, lid from table...
    then can i get the correct data....
    and this table also has some address fields like address1, address2, zip1, zip 2 and i want to find the unique data on teh combintaiton of these columns...
    SELECT all_data.lid,
    NVL(all_data.STREET_LN1_ADDR, 'NULL'),
    NVL(all_data.STREET_LN2_ADDR, 'NULL'),
    NVL(all_data.CTY_ADDR, 'NULL'),
    NVL(all_data.POST_ZIP5_CD, 'NULL'),
    NVL(all_data.POST_ZIP4_CD, 'NULL'),
    NVL(all_data.GEO_ZIP_CD, 'NULL'),
    NVL(all_data.LAT_NO, 0),
    NVL(all_data.LNG_NO, 0),
    NVL(all_data.LAT_LNG_CD, 0)
    FROM CDI_POST_HCP_ALL_DATA_CURR all_data
    in this i want unique data for all these address fields...
    please help me guys...
    Edited by: pusala on Dec 7, 2010 3:53 PM

    SELECT
    NVL(all_data.STREET_LN1_ADDR, 'NULL'),
    NVL(all_data.STREET_LN2_ADDR, 'NULL'),
    NVL(all_data.CTY_ADDR, 'NULL'),
    NVL(all_data.POST_ZIP5_CD, 'NULL'),
    NVL(all_data.POST_ZIP4_CD, 'NULL'),
    NVL(all_data.GEO_ZIP_CD, 'NULL'),
    NVL(all_data.LAT_NO, 0),
    NVL(all_data.LNG_NO, 0),
    NVL(all_data.LAT_LNG_CD, 0),
    count(*)
    FROM CDI_POST_HCP_ALL_DATA_CURR all_data
    group by NVL(all_data.STREET_LN1_ADDR, 'NULL'),
    NVL(all_data.STREET_LN2_ADDR, 'NULL'),
    NVL(all_data.CTY_ADDR, 'NULL'),
    NVL(all_data.POST_ZIP5_CD, 'NULL'),
    NVL(all_data.POST_ZIP4_CD, 'NULL'),
    NVL(all_data.GEO_ZIP_CD, 'NULL'),
    NVL(all_data.LAT_NO, 0),
    NVL(all_data.LNG_NO, 0),
    NVL(all_data.LAT_LNG_CD, 0)If you only want the values where there are duplicates then use
    SELECT
    NVL(all_data.STREET_LN1_ADDR, 'NULL'),
    NVL(all_data.STREET_LN2_ADDR, 'NULL'),
    NVL(all_data.CTY_ADDR, 'NULL'),
    NVL(all_data.POST_ZIP5_CD, 'NULL'),
    NVL(all_data.POST_ZIP4_CD, 'NULL'),
    NVL(all_data.GEO_ZIP_CD, 'NULL'),
    NVL(all_data.LAT_NO, 0),
    NVL(all_data.LNG_NO, 0),
    NVL(all_data.LAT_LNG_CD, 0),
    count(*)
    FROM CDI_POST_HCP_ALL_DATA_CURR all_data
    group by NVL(all_data.STREET_LN1_ADDR, 'NULL'),
    NVL(all_data.STREET_LN2_ADDR, 'NULL'),
    NVL(all_data.CTY_ADDR, 'NULL'),
    NVL(all_data.POST_ZIP5_CD, 'NULL'),
    NVL(all_data.POST_ZIP4_CD, 'NULL'),
    NVL(all_data.GEO_ZIP_CD, 'NULL'),
    NVL(all_data.LAT_NO, 0),
    NVL(all_data.LNG_NO, 0),
    NVL(all_data.LAT_LNG_CD, 0)
    having count(*) > 1

Maybe you are looking for

  • Buggy US keyboard layout on JIS keyboard

    My Mac Aluminum JIS keyboard does not give the proper symbols when using a US layout. Correct me if I am wrong, but I expect the '@' sign when pressing the Shift+'2' key combination. Instead of this I get '"'. Is there any way to get the mapping righ

  • IPhoto 11 import to library from file menu

    When using iPhoto 11, and attempt to import a photo to library from file menu, nothing happens. No error message, no action. I rebuilt the database, tried deleting the cache and plist. Everything seems fine except I cannot use this function. Any idea

  • Hwnd and acrobat plugin

    I'm using opengl and i have a question : is possible to get an hwnd from a pdf document that can use it for draw with opengl through a plugin? How i can render with opengl in acrobat sdk? thanks.

  • AfterEffects error:CT bad param: True type or CFF font expected

    After Effects fro CC will not start up - I am using UTC for fonts - what's the fix?

  • But NOT know how handle figure element in old browsers, well?

    dw cs6 http://www.ancientgreekdramainstitute-cyprus.org/gallery.html here I have a gallery but in Chrome or other modern browse like ie9+/firefox/opera/safari appear OK, in ie8 is a mesh... I have a special css for browsers<=ie8, but NOT know how han