What's wrong with this query?

Results 1 to 2 of 2

Thread: What's wrong with this query?

  1. #1
    Join Date
    Dec 1969

    Default What's wrong with this query?

    What&#039;s wrong with the following query?<BR><BR>[code language="t-sql"]<BR>SELECT Count(*) AS Cnt <BR>FROM (SELECT RoomNo, Count(*) AS Cnt1 <BR> FROM AccommodationUsage <BR> WHERE RoomType=&#039;1 Bed&#039; AND HotelID=1 AND<BR> ArrivalDate&#060;=&#039;3/28/2004&#039; AND <BR> DepartureDate&#062;=&#039;3/28/2004&#039; <BR> GROUP BY RoomNo)<BR>[/code]<BR><BR>It works fine in MS Access (replacing the &#039; with # around the dates, of course), but it doesn&#039;t work at all in SQL Server. I get the error, "Incorrect syntax near &#039;)&#039;". I&#039;ve tried removing the "(*)" around the counts, and I still get the same error. So, the only ")" it could be referring to is the last one.<BR><BR>Any ideas?<BR><BR>Thanks,<BR>Jesse

  2. #2
    Join Date
    Dec 1969

    Default I dunno but you could work around it

    For get the outer SELECT.<BR><BR>Then just open the inner SELECT using an asOpenStatic cursor<BR> RS.Open SQL, conn, adOpenStatic<BR>and do<BR> cnt = RS.RecordCount<BR><BR>

Posting Permissions

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