Results 1 to 4 of 4

Thread: Please help me someone! I cant get this code to work

  1. #1
    Join Date
    Nov 2003
    Location
    Ireland
    Posts
    2

    Please help me someone! I cant get this code to work

    Can anyone PLEASE help me? Im banging my head on the wall in frustration with this.

    Whats wrong with this code?

    SELECT *
    FROM DEUS_DC_V_R_APPLICATIONS
    WHERE (

    ((DEUS_DC_V_R_APPLICATIONS.APPLICATION_NUMBER) Not Like "TE*")

    AND (


    DEUS_DC_V_R_APPLICATIONS.WARD_NAME = "Bowdon" Or
    DEUS_DC_V_R_APPLICATIONS.WARD_NAME = "Broadheath" Or
    DEUS_DC_V_R_APPLICATIONS.WARD_NAME = "Altrincham" Or
    DEUS_DC_V_R_APPLICATIONS.WARD_NAME = "Timperley" Or
    DEUS_DC_V_R_APPLICATIONS.WARD_NAME = "Village" Or
    DEUS_DC_V_R_APPLICATIONS.WARD_NAME = "Hale" )


    AND
    ((DEUS_DC_V_R_APPLICATIONS.DATE_OF_DECISION) Is Null))
    OR
    (((DEUS_DC_V_R_APPLICATIONS.DATE_OF_DECISION)>#3/31/2003#)
    AND
    ((DEUS_DC_V_R_APPLICATIONS.APPLICATION_STATUS_DESC RIPTION)="Recommended"));


    It just ignores the sabout WARD_NAME.


    Id be so grateful if someone was sweet enough to help me.

    Zoe
    xxx

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Check the parentheses to see if AND and OR are properly enclosed as you require.

  3. #3
    Join Date
    Mar 2003
    Posts
    468
    Zoe,
    i have reduced and reformated just so that i could look at this a bit easier.
    hopefully my explaination as to what this sql is doing is what you intended.
    it would be helpful to explain what you meant by ignores. sometimes sample
    data and output is helpful for describing what you are experienceing and we
    can match what you expect to the sql you have given. any how here is my
    explaination of what you have coded.

    1. SELECT * FROM DEUS_DC_V_R_APPLICATIONS WHERE
    2. ( (APPLICATION_NUMBER Not Like "TE*") AND
    3. ( WARD_NAME = "Bowdon" Or
    4. WARD_NAME = "Broadheath" Or
    5. WARD_NAME = "Altrincham" Or
    6. WARD_NAME = "Timperley" Or
    7. WARD_NAME = "Village" Or
    8. WARD_NAME = "Hale" ) AND
    9. (DATE_OF_DECISION Is Null)
    10. )
    11. OR
    12. ((DATE_OF_DECISION > #3/31/2003#) AND
    13. (APPLICATION_STATUS_DESCRIPTION="Recommended")
    14. );



    a. basically if lines 2-10 are true or 12-14 are true for the row being evaluated then the row is returned.
    b. line 2 + lines 3-8 + line 9 must all evaluate to true for lines 2-10 to be true
    c. line 12 + line 13 must both evaluate to true for lines 12-14 to evaluate to true
    d. by ignoring i am assuming you mean that it is not "catching" rows with the values where WARD_NAME = "oneofthevalues"
    i would guess that the reason is that the other two conditions on lines 2 and 9 are not evaluating to true also
    and thus you aren't getting the results you expect.

    if this is not the case then please post sample data and output.
    ~

  4. #4
    Join Date
    Nov 2003
    Location
    Ireland
    Posts
    2

    hiya!

    Thank you Jkoopmann, I really appreciate your help. Im not very good at this kind of stuff.

    Your breakdown helped to clarify what was going wrong with the code.

    By "ignores", you are right I meant "not catching" as you more accurately put it.

    What i was trying to achieve was to code:

    If lines 2-8 are true and either line 9 or lines 12 and 13 are true, then return the row.

    Sorry for not making this clear in my first post.

    If you still require sample data I can make some up for you

    Thanks ever so much for your help.

    luv & hugs

    Zoe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •