SQL Query problem...

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

  1. #1

    Default SQL Query problem...

    Here is a query I am trying to execute.

    SELECT ConsultantPIN, CFirstName, CLastName, Count(DateSubmitted) AS [Total]
    FROM consultant_DS WHERE DateSubmitted >=#02/01/2004# and DateSubmitted
    <=#2/29/2004# Group By ConsultantPIN, CFirstName, CLastName Order By Total
    DESC;

    My problem is that I am trying to use Total from ...Count(DateSubmitted) AS
    [Total].... in the Order By Statement.
    It will not let me. I can use ConsultantPIN, CFirstName or CLastName.

    Any suggestions.

    Thanks,
    Mikeal


    Mike Hill Guest

  2. Similar Questions and Discussions

    1. Query problem, please help.
      mysql Ver 12.22 Distrib 4.0.24, for pc-linux-gnu (i386) gives me: The following database Error occured: You have an error in your SQL syntax....
    2. ***Sql Query problem
      Randy Webb wrote: SELECT DISTINCT OrderID FROM trans WHERE Trans_ID = 1 AND OrderID NOT IN (SELECT DISTINCT OrderID FROM trans WHERE Trans_ID =...
    3. Query of Query problem
      Error Executing Database Query. Query Of Queries runtime error. Table named "DATA" was not found in Memory. It is misspelled, or the table is...
    4. Query on Query and CF casting problem
      I am using a custom tag in MX7 that was working fine in 5 that renders a table. The input to the custom tag is a query and it's columns along with...
    5. query problem
      SELECT top5.PRODID, p.PRODNAME FROM ( SELECT TOP 5 SALES = COUNT(*), PRODID FROM SALES GROUP BY PRODID ORDER BY SALES DESC ) AS top5 INNER JOIN...
  3. #2

    Default Re: SQL Query problem...

    ORDER BY Count(DateSubmitted) DESC

    ?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    "Mike Hill" <mhill7272(at)hotmail.com> wrote in message
    news:OnDTz3DGEHA.3984@TK2MSFTNGP10.phx.gbl...
    > Here is a query I am trying to execute.
    >
    > SELECT ConsultantPIN, CFirstName, CLastName, Count(DateSubmitted) AS
    > [Total]
    > FROM consultant_DS WHERE DateSubmitted >=#02/01/2004# and DateSubmitted
    > <=#2/29/2004# Group By ConsultantPIN, CFirstName, CLastName Order By Total
    > DESC;
    >
    > My problem is that I am trying to use Total from ...Count(DateSubmitted)
    > AS
    > [Total].... in the Order By Statement.
    > It will not let me. I can use ConsultantPIN, CFirstName or CLastName.
    >
    > Any suggestions.
    >
    > Thanks,
    > Mikeal
    >
    >

    Aaron Bertrand [MVP] Guest

  4. #3

    Default Re: SQL Query problem...

    Thanks!
    That did it.

    "Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
    news:O$Bu56DGEHA.3724@TK2MSFTNGP11.phx.gbl...
    > ORDER BY Count(DateSubmitted) DESC
    >
    > ?
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > [url]http://www.aspfaq.com/[/url]
    >
    >
    > "Mike Hill" <mhill7272(at)hotmail.com> wrote in message
    > news:OnDTz3DGEHA.3984@TK2MSFTNGP10.phx.gbl...
    > > Here is a query I am trying to execute.
    > >
    > > SELECT ConsultantPIN, CFirstName, CLastName, Count(DateSubmitted) AS
    > > [Total]
    > > FROM consultant_DS WHERE DateSubmitted >=#02/01/2004# and DateSubmitted
    > > <=#2/29/2004# Group By ConsultantPIN, CFirstName, CLastName Order By
    Total
    > > DESC;
    > >
    > > My problem is that I am trying to use Total from ...Count(DateSubmitted)
    > > AS
    > > [Total].... in the Order By Statement.
    > > It will not let me. I can use ConsultantPIN, CFirstName or CLastName.
    > >
    > > Any suggestions.
    > >
    > > Thanks,
    > > Mikeal
    > >
    > >
    >
    >

    Mike Hill 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