Access 2k SQL Statement

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Access 2k SQL Statement



    I am trying to get the SQL statement right for querying an Access 2k
    database

    I would like to obtain the first record of Event A and the last record
    of Event B of each day.

    This is what I have for a query. When I run it, I get "Syntax Error
    (Missing Operator)in query expression LAST [Table].[Event]" (Table name
    has been changed to protect the guilty)

    SELECT TOP 1 [Table].[Event], [Table].[Customer], [Table].[Date&Time]
    FROM Table
    WHERE ((([Table].[Event])="FirstEvent") And
    (([Table].[Customer])="ACME") And
    (([Table].[Date&Time])=DateValue("December 15, 2003")))
    UNION SELECT LAST [Table].[Event], [Table].[Customer],
    [Table].[Date&Time]
    FROM Table
    WHERE ((([Table].[Event])="Final") And (([Table].[Customer])="ACME") And
    (([Table].[Date&Time])=DateValue("December 15, 2003")))
    ORDER BY [Table].[Date&Time];


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    HallMonitor89 Guest

  2. Similar Questions and Discussions

    1. Having Problems With SQL Statement[ACCESS DB]
      Hi, This is my SQL Procedure : IFF(21 in(SELECT PageID FROM TBL_Trafic WHERE PageID=21), (UPDATE TBL_Trafic SET Hits=Hits+1,...
    2. Show Access DB-content with i.e. WHEN-statement??
      I have a database with an autoincrement ID-column and a ParentID-column. Its used in a sort of "thread-environment" When a new thread is...
    3. access insert statement
      have you tried? was there an error? I'm not sure that Access has the "@@identity".... I'd suggest trying and posting the specific errors. --...
    4. pass sql where statement into access report
      I am trying to automate production of an Access report via ASP. I have almost got there apart from the fact that I want to send either an SQL...
    5. Statement Conversion Access -> mySQL
      SQL = "DELETE FROM table WHERE ID IN (1, 9, 15, 20)" The above statement is for deleting records in access using checkboxes on a form (deletes...
  3. #2

    Default Re: Access 2k SQL Statement

    Try:

    LAST([Table].[Event])

    or also use TOP 1 in conjuction with ORDER BY something DESC

    Ray at home

    "HallMonitor89" <nospam@novirus.com> wrote in message
    news:OPX3ccPxDHA.1364@tk2msftngp13.phx.gbl...
    >
    >
    > I am trying to get the SQL statement right for querying an Access 2k
    > database
    >
    > I would like to obtain the first record of Event A and the last record
    > of Event B of each day.
    >
    > This is what I have for a query. When I run it, I get "Syntax Error
    > (Missing Operator)in query expression LAST [Table].[Event]" (Table name
    > has been changed to protect the guilty)
    >
    > SELECT TOP 1 [Table].[Event], [Table].[Customer], [Table].[Date&Time]
    > FROM Table
    > WHERE ((([Table].[Event])="FirstEvent") And
    > (([Table].[Customer])="ACME") And
    > (([Table].[Date&Time])=DateValue("December 15, 2003")))
    > UNION SELECT LAST [Table].[Event], [Table].[Customer],
    > [Table].[Date&Time]
    > FROM Table
    > WHERE ((([Table].[Event])="Final") And (([Table].[Customer])="ACME") And
    > (([Table].[Date&Time])=DateValue("December 15, 2003")))
    > ORDER BY [Table].[Date&Time];
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Ray at Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139