Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. difficult query

difficult query

Scheduled Pinned Locked Moved Database
databaseoracle
9 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m_safaaaa
    wrote on last edited by
    #1

    hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

    Richard Andrew x64R P P S V 7 Replies Last reply
    0
    • M m_safaaaa

      hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      What have you tried so far?

      The difficult we do right away... ...the impossible takes slightly longer.

      1 Reply Last reply
      0
      • M m_safaaaa

        hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        m_safaaaa wrote:

        Please it's urgent

        That's a big no no to say in a forum post. People will help you when they can. As the other poster has mentioned, what have you tried so far?

        ""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        1 Reply Last reply
        0
        • M m_safaaaa

          hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          I suspect that 2012-05-30 just might possibly be between the date_of_birth and the date_of_death (or some date in the future if null). :~ You are using DATE or DATETIME fields, right? Right?

          1 Reply Last reply
          0
          • M m_safaaaa

            hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

            S Offline
            S Offline
            Sandeep Mewara
            wrote on last edited by
            #5

            Posting in multiple forums is considered rude. Please find an appropriate forum and stick to it: Difficult query please it's urgent[^]

            Sandeep Mewara [My last tip/trick]: Server side Delimiters in ASP.NET[^]

            1 Reply Last reply
            0
            • M m_safaaaa

              hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

              V Offline
              V Offline
              vvashishta
              wrote on last edited by
              #6

              SELECT * FROM Applicant WHERE Date_Of_Death > CONVERT(VARCHAR,'30-05-2012',106) - Happy Coding - Vishal Vashishta

              B 1 Reply Last reply
              0
              • M m_safaaaa

                hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

                B Offline
                B Offline
                Bernhard Hiller
                wrote on last edited by
                #7

                Either date_fo_death is null or greater than the given date:

                SELECT *
                FROM Applicant
                WHERE date_of_death is null
                OR date_of_death>@somedate

                1 Reply Last reply
                0
                • V vvashishta

                  SELECT * FROM Applicant WHERE Date_Of_Death > CONVERT(VARCHAR,'30-05-2012',106) - Happy Coding - Vishal Vashishta

                  B Offline
                  B Offline
                  Bernhard Hiller
                  wrote on last edited by
                  #8

                  Works great, if the guy is still alive today... Your query selects all who have already died past that date - that's a difference.

                  1 Reply Last reply
                  0
                  • M m_safaaaa

                    hello, I have a table named: 'Applicant' having fields: 'id_Applicant', 'name,'date_of_birth','date_of_death' the sql or oracle query is: 'Select all applicant who are alive on 30-05-2012' Please it's urgent thanks alot.

                    M Offline
                    M Offline
                    Michael Potter
                    wrote on last edited by
                    #9

                    SELECT
                    id_Applicant,
                    name,
                    date_of_birth,
                    date_of_death
                    FROM
                    Applicant
                    WHERE
                    '5/30/2012' BETWEEN date_of_birth AND ISNULL(date_of_death,'1/1/3000')

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups