Results 1 to 7 of 7
  1. #1
    zoe.ohara is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    3

    syntax error in query

    Hi,



    I have a table that has a numeric field 'TransferNo'
    Im trying to write a query that calculates the total number of records that have a TransferNo that is GREATER than the average of all the TransferNo in that table.

    My expression is:

    SELECT Count(*) AS Result
    FROM Table1
    WHERE (
    ([Table1.TransferNo])>(AVG[Table1.TransferNo])
    );


    I keep getting syntax errors. Anyone know what the problem is?

    Thanks,

    Zoe

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    SELECT Count(*) AS Result
    FROM Table1
    WHERE (
    ([Table1.TransferNo])>DAVG("TransferNo","table1")
    );

  3. #3
    zoe.ohara is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    3
    Hi, thanks for the help! Unfortunatley that gives me:

    Data Mismatch in criteria expression

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    is "transferNo" a number field?
    if is, data type should match; if not, there is no average on transferNo.

  5. #5
    zoe.ohara is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2010
    Posts
    3
    Quote Originally Posted by weekend00 View Post
    is "transferNo" a number field?
    if is, data type should match; if not, there is no average on transferNo.
    Yes its a number field

    Cant understand why its not working

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Please convert DAVG to the same data type of transferNo, e.g. if transferNo is long integer:

    SELECT Count(*) AS Result
    FROM Table1
    WHERE (
    ([Table1.TransferNo])>clng(DAVG("TransferNo","table1"))
    );

  7. #7
    ivanver is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    3
    Try, if you are still interested:

    SELECT Count(*) AS Result
    FROM Table1 t
    WHERE
    t.TransferNo>(select AVG (tn.TransferNo)
    from Table1 tn);

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Syntax Error in Query Expression on filter
    By alaric01 in forum Forms
    Replies: 1
    Last Post: 10-14-2010, 07:23 AM
  2. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  3. Syntax error (comma) in query expression?
    By TheWolfster in forum Queries
    Replies: 5
    Last Post: 05-10-2010, 12:02 PM
  4. Syntax error (comma) in query expression
    By KLynch0803 in forum Programming
    Replies: 3
    Last Post: 01-18-2010, 03:35 AM
  5. Replies: 1
    Last Post: 10-07-2009, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums