Query to retrieve Identical names, same birth dates

I have a table with these fields:
table1 definition
(ID varchar2(10),
name1 varchar2(50),
name2 varchar2(50),
name3 varchar2(50),
name4 varchar2(50),
birthdt date)
I need to write a query to retrieve the id's of those people that have identical first and last names AND were born on the same date. note that name is composed of four parts.
I am trying this query
(select id from table1 group by name1,name4,birthdt having count(name1)>1 and count(name4)>1 and count(birthdt)>1). I am not getting correct results.
Any help appreciated.
Ammar

¿...Doh...how could I miss that? smacks forehead
Thanks ( for the N-th time ;) ) for setting straight, Solomon.
Guess I wasn't completely recovered from yesterday ;)
However, the basic approach wasn't too bad ;)
But ofcourse the 'select *' should be 'select id'
Using testdata:
SQL> with table1 as ( -- generating sample data as I should have done in the first place:
  2  select 1 id, 'John' name1, 'James' name2, 'Joe' name3, 'Jameson' name4, to_date('15-05-1989','dd-mm-yyyy') birthdt from dual union all
  3  select 2 id, 'John' name1, 'James' name2, 'Joe' name3, 'Jackson' name4, to_date('15-05-1989','dd-mm-yyyy') birthdt from dual union all
  4  select 3 id, 'John' name1, 'James' name2, 'Joe' name3, 'Jameson' name4, to_date('25-05-1989','dd-mm-yyyy') birthdt from dual union all
  5  select 4 id, 'Zlad' name1, 'James' name2, 'Joe' name3, 'Jameson' name4, to_date('15-05-1989','dd-mm-yyyy') birthdt from dual union all
  6  select 5 id, 'John' name1, 'James' name2, 'Joe' name3, 'Jameson' name4, to_date('15-05-1989','dd-mm-yyyy') birthdt from dual
  7  )
  8  --
  9  -- actual query
10  --
11  select id
12  from ( select id
13         ,      name1
14         ,      name2
15         ,      name3
16         ,      name4
17         ,      birthdt
18         ,      count(*) over (partition by name1, name2, name3, name4, birthdt) recs
19         from   table1
20       )
21  where recs > 1;
        ID
         1
         5

Similar Messages

  • Query That Retrieves New Customers & Leads By Date

    Hello All --
    We would like to create a Query that retrieves new customers and leads based on the date (or date range) they are entered into SAP. 
    Can we create a UDF named STDATE --- Start Date -- and have a Query that allows us to select based on this date range?
    Start dates are entered in this format --- YYYYMMDD.
    Then, the Query would pull out:
    Contact...Company...Bill To Address...Bill To City...Bill To State....Bill To Zip...Phone...Email
    Is this possible to do?
    Thanks!
    Mike

    Hi Mike ,
    You can add some other field as you like .This report will give you combination of both customer and lead .
    I couldn't understand the purpose ,but I like previous query as i have flexibilty to choose customer or vendor .
    SELECT T0.[CreateDate], T0.[CntctPrsn], T0.[CardName], T0.[Address], T0.[City], T0.[E_Mail], T0.[ZipCode], T0.[Phone1] FROM OCRD T0 WHERE T0.[CardType] in ('C','L') and T0.[CreateDate]=[%0]
    If you agree with me ,you can use this query
    SELECT T0.[CreateDate], T0.[CntctPrsn], T0.[CardName], T0.[Address], T0.[City], T0.[E_Mail], T0.[ZipCode], T0.[Phone1] FROM OCRD T0 WHERE T0.[CardType] =[%0] or T0.[Cardtype]=[%1] and
    T0.[CreateDate]=[%2]
    Regarding the date issue , since you are entering paramenter it will match with the date you are looking for .If you have more than one customer created on same day , you willreceive multiple client .
    Thank you
    Bishal

  • Query to retrieve user Authorizations

    Dear Experts,
    Is there anyone with a query to retrieve user names and their respective authorizations.
    Regards

    As now are aware that Authorization table is not exposed,you can export the authorization as suggested by one of the forum member.
    When Exporting the Authorisation the list of user name will be imported first and then the list of authorisation second.
    In order to have all the authorisations you will need to expand all the menu and sub menu.
    Adminitstration -> system initialisation -> System initialisation -> Authorisations -> General authorisations
       1. In the Authorisations window
       2. Click on expand
       3. With the Authorisations' window active click on Excel icon or go to File -> Export -> Export to MS Excel
       4. In the first 'Save as' window opening
       5. Name your 'User' file and select the relevant folder
       6. At the system message popping :'Do you want to export currency symbols ?'
       7. Click independently on 'Yes' or 'No'.
       8. A security warning message will appear.
       9. Click on 'Enable Macros'
      10. A second 'Save as' window is opened.
      11. Name your 'Authorisations list' file differently.
      12. Execute again step 6 to 9
    The two files will then open. One with the list of users one with the list of authorisations

  • Web Analysis Error -- Error while executing query and retrieving data

    Regarding Web Analysis:
    We have a number of reports that we created. yesterday they were all working fine. today we try to open them and most are generating an error.
    The error is:
    Error while executing query and retrieving data.; nested exception is:
    com.hyperion.ap.APException: [1033] Native:
    1013033[Thu Oct 22 09:08:17
    2009]server name/application name/database name/user name/Error91013033)
    ReportWriter exit abnormally
    Does anyone have any insight into what is going on?
    My version information is:
    Hyperion System 9 BI+ Analytic Administration Services 9.3.0.1.1 Build 2
    Web Analysis 9.3.0.0.0.286
    Thanks in advance for your help.
    DaveW

    Hi,
    And also click on check option by opening the query in Query designer,as Mr . Arun suggested.
    And if you get any error in checking, see the long message(detail).
    With rgds,
    Anil Kumar Sharma .P

  • BUG: "Don't Import Suspected Duplicates" FAILS for two identical files (same name, same MD5)

    Using LR 4.4, I'm seeing duplicate files not detected when the files have the same name and identical content (same MD5).
    Adobe support takes me here, although I'd rather file a bug.
    I've isolated a small test case where I have a directory with a small number of images (taken at the same time with the same camera.)
    I can copy this directory to a different location, then try to import it and one of the files will not be detected as a dupe.
    I've tried re-reading the metadata for the existing library file.
    Files have the same name and same checksums.

    According to the Lightroom documentation
    Lightroom determines a photo is a duplicate of another file in the catalog if it has the same, original filename; the same Exif capture date and time; and the same file size
    Please confirm that your "duplicate" files meet this criterion

  • Query to retrieve date depending on specific date

    hi all,
    i have a question regarding dates.
    ihave a table with following data
    with table1 as
      select 123 id, 'text' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 111 id, 'text2' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 222 id, 'text3' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 333 id, 'text4' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 444 id, 'text5' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual union all
      select 555 id, 'text6' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual union all
      select 666 id, 'text7' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual union all
      select 777 id, 'text8' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual
    )i am creating a procedure that will insert data into a table and this procedure will run every day.
    so for example, if procedure runs today, then it will check today's date against table1 and see we have
    4 rows for 9/16/2010 and insert into a table. then tomorrow 9/17/2010 it will see if there is a 9/17/2010 data.
    since there is no data, then the 4 rows with 9/16/2010 should be pick up and inserted with 9/17/2010 date.
    now lets say that today is 9/20/2010 then the query should pick up 9/20/2010 data set.
    for 9/21/2010 the same data set for 9/20/2010 should be pick since that is the latest date less than or equal to 9/21/2010
    here is sample output.
    lets say we run query today. then output should be
    id     txt       date1
    ================================
    123     text     09.16.2010  
    111     text2     09.16.2010
    222     text3     09.16.2010
    333     text4     09.16.2010 now lets say today is 9/17/2010 then query will look at table for the 9/17/2010, since it is not found
    it will be pick the latest less than or equal to 9/17/2010
    output should be
    id     txt       date1
    ================================
    123     text     09.17.2010  
    111     text2     09.17.2010
    222     text3     09.17.2010
    333     text4     09.17.2010 now lets say that today is 9/20/2010, the query will look at the table for date 9/20/2010, it found there there is an entry and will pick up that data set.
    so output should be
    444     text5     09.20.2010
    555     text6     09.20.2010
    666     text7     09.20.2010
    777     text8     09.20.2010if you run for 9/21/2010 , query should pick up latest date less or equal to 9/21/2010 which is 9/20/2010 so output should be
    444     text5     09.21.2010
    555     text6     09.21.2010
    666     text7     09.21.2010
    777     text8     09.21.2010can someone help write a query that given a date can retrieve output above? thanks

    with table1 as
      select 123 id, 'text' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 111 id, 'text2' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 222 id, 'text3' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 333 id, 'text4' txt, to_date('9/16/2010','mm/dd/yyyy') date1 from dual union all
      select 444 id, 'text5' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual union all
      select 555 id, 'text6' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual union all
      select 666 id, 'text7' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual union all
      select 777 id, 'text8' txt, to_date('9/20/2010','mm/dd/yyyy') date1 from dual
    /* substitute trunc(sysdate) with your parameter */
    select t.id, t.txt, trunc(sysdate)  as date1 from table1 t
    where t.date1=(select max(t2.date1) from table1 t2 where t2.date1 <= trunc(sysdate) )

  • How to write a sql query to retrieve data entered in the past 2 weeks

    Hi,
    I have file names and last accessed date(java.sql.Date format) stored in my database table, I would like to know how I can write a query to get the name of files accessed in the past 2 weeks,I use open sql server at the back end.
    Thanks in advance.

    This has essentially nothing to do with JDBC. JDBC is just an API to execute the SQL language using Java and thus interact with the databases.
    Your problem is related to the SQL language, you don't know how to write the SQL language. I suggest you to go through a SQL tutorial (there is one at w3schools.com) and to read the SQL documentation which come along with the database in question. A decent database manfacturer has a website and probably also a discussion forum / mailinglist as well.
    I'll give you a hint: you can just use equality operators in SQL like everywhere. For example: "WHERE date < somedate".

  • Same Input name with different data type cause the reflection exception

    I have a proxy contains couple RFCs. Two RFCs contain an argument named IN_COMPANY_CODE with data type of ZTRE_FX_BUKRSTable. Another RFC contains the same argument name of IN_COMPANY_CODE but hold different data type (String). All RFCs are in the same proxy. Complie and build the application with no issue.
    But when I ran the RFC, it generates the reflection exception below:
    Method SAPProxy1.Z_F_Tre_R_Pre_Trade_Fx can not be reflected. --> There was an error reflecting 'In_Company_Code'. > The XML element named 'IN_5fCOMPANY_--5fCODE' from namespace '' references distinct types System.String and MSTRFOREX.ZTRE_FX_BUKRSTable. Use XML attributes to specify another XML name or namespace for the element or types.
    I realize the conflict introduced by the same name with difference data type. But I would like to know if this is fixable as a bug or if there is any best practice and/or some manual intervention to make it work.

    Please install fix from OSS note 506603. After this, right-click .sapwsdl file and select "Run custom tool".

  • Is there any way I can program "Capture" to save pnp.picts always under the same name, without a date ?

    Is there any way I can program "Capture" to save pnp.picts on the desk, but always under the same name, without a date ?
    It may be sound weird, but I use it in a very special way, and I would like, like photoshop, that capture just replace
    the previous pict by the new one..without any warning.
    Pierre

    There is no way to go back from an XFA form to an Acroform even with Acrobat Pro, still less with Acrobat. You either need to remake the form, or change your plans to use a third party viewer - Adobe have an excellent range of programs they would like you to use!

  • CSCul66951 LDAP routing query fails when user name is the same (6 july 2014)

    in the case CSCul66951 LDAP routing query fails when user name is the same it is mentionned that the version 8.0.2-055 correct this bug ? How come i don't see this version on my menu Available upgrades from my IronPort C370 ?
    Is there someone on the support team that have try this LDAP query on a IronPort C370 with this version in the development lab ?
    Do i have to open a support Case to have this version of AsyncOS ?
    Best regards,
    Benoit Belair
    University of Quebec in Montreal

    Yes - CSCul66951 - this was included w/ the 8.0.1-HP1, and is rolled into 8.5.6-074 GA release.
    See release notes, resolved issues:
    http://www.cisco.com/c/dam/en/us/td/docs/security/esa/esa8-0/release_notes/ESA_8-0-1_HP1_Release_Notes.pdf
    CSCun02766 - 8.5.6-063, which was superseded by the 8.5.6-074 GA release.  
    See release notes, resolved issues:
    http://www.cisco.com/c/dam/en/us/td/docs/security/esa/esa8-5-6/ESA_8-5-6_Release_Notes.pdf

  • Every time I create an account with iCloud then try to open it I get wrong ID or password. Even when I enter my birth date I am told it is incorrect. I have done this several times with the same results.

    Every time I create an account with iCloud then try to open it I get an error message: wrong ID or password. Also when I enter my birth date I am told it is incorrect. I have done this several times with the same results.

    Oldcameraman
    Please do not duplicate a thread. The threads are answered as soon as possible. We are not Adobe. Just user to user.
    I have answered your most recent of the duplicates
    Premier Elements 13 Organizer Works. Editor doesn't. Log in doesn't work
    It is uncertain just how far we can go to help you since you do not appear to have Premiere Elements any
    longer.Seems you demanded a refund from Adobe Chat, got it, and now are left with a non purchased program which I
    am not sure can be used.
    Duplicates tend to confuse the person asking the question as well as those attempting to reply. As I suggested in the
    above mentioned thread, try to sort out your situation with Adobe via its Adobe Chat.
    ATR

  • Need a Query that Returns both Column Name with Column Data

    Hi,
    Hope someone can assist quite quickly. I'm after a query that will return me both column name together with column data, i.e
    Table: APP_INFO
    COL1  - currently has the value of 10
    COL2  - currently has the value of 'HELLO'
    COL3  - currently has the value of 'QWERTY'
    COL4  - currently has the value of 2000Query I'm after is to return the following result set: [actual column name, actual column data]
    COL1,10
    COL2,'HELLO',
    COL3,'QWERTY'
    COL4,2000
    Any help would be much appreciated.
    Thanks.
    Tony.

    Like this ?
    SQL> select empno, ename, deptno from emp where deptno = 10;
         EMPNO ENAME          DEPTNO
          7782 CLARK              10
          7839 KING               10
          7934 MILLER             10
    SQL> select decode(t.id,1,'EMPNO',2,'ENAME',3,'DEPTNO') COLNAME,
      2  decode(t.id,1,to_char(empno),2,ename,3,deptno)
      3  from (select emp.*, rownum rn from emp
      4  where deptno = 10) emp, (select rownum id from dict where rownum <=3) t
      5  order by emp.rn, t.id
      6  /
    COLNAM DECODE(T.ID,1,TO_CHAR(EMPNO),2,ENAME,3,D
    EMPNO  7782
    ENAME  CLARK
    DEPTNO 10
    EMPNO  7839
    ENAME  KING
    DEPTNO 10
    EMPNO  7934
    ENAME  MILLER
    DEPTNO 10
    9 rows selected.Rgds.

  • Need efficient SQL query to retrieve data for MLM website

    Table cd_members
    MemberID LeftID RightID
    1 2 3
    2 4 5
    3 6 7
    4 8 -
    5 - -
    6 - -
    7 - -
    8 9 10
    9 - -
    10 - -
    i want to execute a query to retrieve downline of a member say MemberID 2
    o/p should be Records with MemberID 4,5,8,9,10
    i am using this query but don't know how to start from MembeID=2
    select a.memberid, a.tradingid, a.refid, a.parentid, a.node, a.leftid, a.rightid, b.memberid from cd_members a, cd_members b
    where (a.leftid=b.memberid or a.rightid=b.memberid)

    Again, assuming that the number of levels is known, you can just do N self joins (note that I intentionally go one level further than necessary in this case
    SQL> ed
    Wrote file afiedt.buf
      1  with t
      2    as
      3   (
      4      select 1 person, 2 left, 3 right from dual union all
      5      select 2, 4, 5 from dual union all
      6      select 3, 6, 7 from dual union all
      7      select 4, 8, null from dual union all
      8      select 5, null, null from dual union all
      9      select 6, null, null from dual union all
    10      select 7, null, null from dual union all
    11      select 8, 9, 10 from dual union all
    12      select 9, null, null from dual union all
    13      select 10, null, null from dual
    14   )
    15   select t1.left, t1.right, t2.left, t2.right, t3.left, t3.right, t4.left, t
    4.right
    16     from t t1,
    17          t t2,
    18          t t3,
    19          t t4
    20    where t1.person = 2
    21      and t1.left = t2.person(+)
    22      and t2.left = t3.person(+)
    23*     and t3.left = t4.person(+)
    SQL> /
          LEFT      RIGHT       LEFT      RIGHT       LEFT      RIGHT       LEFT
         RIGHT
             4          5          8                     9         10Justin

  • ERROR MESSAGE WHEN DOING SIMPLE QUERY TO RETRIEVE LARGE AMOUNT OF DATA

    Hello,
    Am querying my database(mysql) and displaying my data in a
    DataGrid (Note that am using Flex 2.0)
    It works fine when the amount of data populating the grid is
    not much. But when I have large amount of data I get the following
    error message and the grid is not populated.
    ERROR 1
    faultCode:Server.Acknowledge.Failed
    faultString:'Didn't receive an acknowledge message'
    faultDetail: 'Was expecting
    mx.messaging.messages.AcknowledgeMessage, but receive Null'
    ERROR 2
    faultCode:Client.Error.DeliveryInDoubt
    faultString:'Channel disconnected'
    faultDetail: 'Channel disconnected before and acknowledge was
    received'
    Note that my datagrid is populated when I run the query on my
    Server but does not works on my client pcs.
    Your help would br greatly appreciated here.
    Awaiting a reply.
    Regards

    Hello,
    Am using remote object services.
    USing component (ColdFusion as destination).

  • Query For Retrieving Data With Date

    Hi Guys
    I am having a hard time to figure out the sql query.
    I have a table with data. Below is the illustration.
    date location
    item
    1 jan 14 A
    apple
    2 jan 14 A
    apple
    3 jan 14 B
    apple
    4 jan 14 B
    apple
    1 jan 14 A
    orange
    2 jan 14 A
    orange
    3 jan 14 B
    orange
    4 jan 14 B
    orange
    My question it how to get the latest date on each location and item
    This is the result I want
    date location
    item
    2 jan 14 A
    apple
    4 jan 14 B
    apple
    2 jan 14 A
    orange
    4 jan 14 B
    orange
    Thanks.

    Try the below:
    create table #temp (sdate datetime,location char(1),Item varchar(20))
    insert into #temp values('1 jan 14','A','Apple')
    insert into #temp values('2 jan 14','A','Apple')
    insert into #temp values('3 jan 14','B','Apple')
    insert into #temp values('4 jan 14','B','Apple')
    insert into #temp values('1 jan 14','A','Orange')
    insert into #temp values('2 jan 14','A','Orange')
    insert into #temp values('3 jan 14','B','Orange')
    insert into #temp values('4 jan 14','B','Orange')
    ;With cte as
    Select * , Row_Number()Over(partition by location, item order by sdate desc) Rn
    From #Temp
    Select * From cte Where rn=1 Order by Item asc,location asc
    drop table #temp

Maybe you are looking for

  • Ipad won't sync, tried everything

    After installing IOS 7 AND the latest version of iTunes, my iPad stopped syncing with my computer. I get the "Your iPad did not sync because the sync session failed to start" message. I also get a "A required iTunes component is not installed. Please

  • CUC Voicemail Issue

    Hi all Currently running CUC 10.x. User voicemail box was working fine. However, configured Unified Messaging and I can leave a voicemail for several users which illuminates the MWI on the phone and appears in email format. Problem is that I get prom

  • My top 5 items i'd like to see in the next FCX update...

    hopefully someone from Apple development reads this! Allow custom frame sizes for projects. a MUST!  not everyone is creating movies in a standard video format - videos are needed for e-commerce, display panels, and web banners that wont fall into a

  • Can I turn a tool recorded artwork into a video?

    I want to show a video turning into a drawing. Can I use the tool recording feature to change my photo into a drawing and than export that to video?

  • Studio displays and G4

    Will an Apple 21" studio display with the built in 4-port USB hub work with a sawtooth G4? I believe these have a 15 pin VGA, right?