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

  • SEARCH
  • Home
  • 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 8569833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:25:39+00:00 2026-06-11T18:25:39+00:00

In SQL, 3 tables joined together, retreving 3 values: value , time , value_name

  • 0

In SQL, 3 tables joined together, retreving 3 values: value, time, value_name. Value is the one I want averaged by day, time is in datetime format on about 10 mins – this one I want it to be converted in day to day, resulting in one row for every day – and my value_name witch cand be any selected value.

Here is my syntax:

select time.entry_time, value_type.value_name, 
       avg(value.value) AVG_VALUE
FROM Value
inner join time on value.time_id = time.id
inner join value_type on value.type_id = value_type.id
WHERE value_type.value_name = 'CUSTOM'
GROUP BY DATEPART(DAY, time.entry_time)

Here I get an error:

Column time.entry_time is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Can you please help me with this syntax?

  • 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-11T18:25:41+00:00Added an answer on June 11, 2026 at 6:25 pm

    Two problems:

    1. You select time.entry_time, but are grouping on DATEPART(DAY, time.entry_time). Which entry time do you want? Did you mean to select DATEPART(DAY, time.entry_time) instead?

    2. You are not grouping by value_type.value_name. You will need to add this to the GROUP BY clause. (Yes, even though there will only be one value ‘CUSTOM’).

    Try:

    select DATEPART(DAY, time.entry_time), value_type.value_name, 
           avg(value.value) AVG_VALUE
    FROM Value
    inner join time on value.time_id = time.id
    inner join value_type on value.type_id = value_type.id
    WHERE value_type.value_name = 'CUSTOM'
    GROUP BY DATEPART(DAY, time.entry_time), value_type.value_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have two joined tables in a SQL Server database, one with news
I have joined together several tables to get data i want but since I
I've done some complex SQL queries, but never joined two tables by multiple values,
When I create SQL tables and I want to refer to a membership provider
I have several tables that get JOINed together to form a table with columns
I have two sql tables Players and Teams joined by a PlayerTeam junction table.
Scenario: I have 3 tables needing to be joined together, a where clause to
I have 2 tables (photos, photos_details) joined by a LEFT JOIN and I want
I have two Sql Server tables accessed through Entity Framework 4. They are joined
I have an SQL query that selects from two inner joined tables. The select

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.