Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:20:56+00:00 2026-06-05T07:20:56+00:00

I’m writing a database query that will show me where there is a space

  • 0

I’m writing a database query that will show me where there is a space for parking. It is only used in July.

There is one table that shows all the spaces and whether they are rented that day. There is another table that has the spaces and their sizes. I want to be able to select those spaces that are available on all the days within the selected time period and have the correct size.

I am having a problem, though, selecting only the spaces available within the given time period. Here is the query so far but it does not contain anything concerning the space size as I want this part to work first.

  SELECT C.Plads, SUM[C.optaget] C.[ledlig] FROM
  (SELECT Plads FROM OptagetPladser AS A Inner JOIN Bådpladser as B ON  
  A.plads=B.Pladsnummer
  WHERE
  (A.dato>=" + Startdato + "and A.dato<="+Slutdato+") //checking the time period
  and (a.optaget = 0))                           //0 means the space is availible
  as C 
  GROUP BY C.Plads 
  HAVING SUM(C.optaget) >="+ diffResult+")";//diff result is the timespan

At the moment I’m getting the error

Syntax error (missing operator) in query expression ‘SUM[C.optaget]’

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:20:57+00:00Added an answer on June 5, 2026 at 7:20 am

    First of all, you should rework your SQL query – it contains too many simple errors.

    Here are a few.

    • Try adding a ‘,’ and make some changes in query:

      SELECT C.Plads, SUM(C.optaget), C.ledlig FROM

    • Your subquery C doesn’t have an optaget and ledlig fields too. To fix this add those fields right after sebquery’s SELECT

    • Fix a syntax error here:

      (A.dato>=" + Startdato + "and A.dato<="+Slutdato+") which should be:

      (A.dato >= " + Startdato + " and A.dato <= "+Slutdato+")

    • Your last double quote is redundant as well as last ‘)’. Remove it:

      HAVING SUM(C.optaget) >= "+ diffResult+" ;//diff result is the timespan

    Below is how your SQL query should look. Please, note: there are still missing fields optaget and ledlig in subquery C.

    SELECT C.Plads, SUM(C.optaget), C.ledlig FROM
    (
        SELECT Plads FROM OptagetPladser AS A 
        INNER JOIN Bådpladser as B 
        ON A.plads = B.Pladsnummer
        WHERE (A.dato >= " + Startdato + " AND A.dato <= " + Slutdato + ")
          AND (a.optaget = 0)
    )
    AS C 
    GROUP BY C.Plads 
    HAVING SUM(C.optaget) >= " + diffResult + ";
    

    I believe, there could appear an architectural or performance issues, but without table data I can’t say it for sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.