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 6332429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:15:44+00:00 2026-05-24T18:15:44+00:00

I have a relatively simple pivot/transform query, which appears as follows: TRANSFORM Sum(T1.VALUE) As

  • 0

I have a relatively simple pivot/transform query, which appears as follows:

TRANSFORM Sum(T1.VALUE) As SumOfVal
SELECT    T1.DATE, T1.HOUR
FROM      T1
WHERE     (T1.DATE = #1/1/2010#)          AND
          (T1.NAME IN ("name1", "name2")) AND
          (T1.TYPE IN ("type1", "type2"))
GROUP BY  T1.DATE, T1.HOUR
PIVOT     T1.NAME + " " + T1.TYPE

Which returns me something like this:

  DATE   | HOUR | name1 type1 | name1 type2 | name2 type1 | name2 type2
------------------------------------------------------------------------
1/1/2010 |   1  |    222.22   |   123.11    |   1241.23   |   133124
1/1/2010 |   2  |    252.22   |   121.11    |    121.23   |   122150

And so on. Now, in another table (with a similar layout), I have more readings which I want to join to the end of the query as another column. The DATE and HOUR will match up exactly, and I can manually specifiy which name/type to use from the table.

Where I’m stuck is, how would I add this into the query? I tried to INNER JOIN the two tables in the FROM clause, and then added the column name to the SELECT clause, but it complained that the field name was not part of the aggregate function. I also tried to add it to the TRANSFORM clause (and the PIVOT clause), but I don’t think you can specify multiple fields for them.

Is this possible to do in a single query using SQL, or do I need to perform both queries separately?


One last note – the query still works after I INNER JOIN table T1 with T2 on the date/hour values (as it should). I just don’t know how to include the actual reading/value so it shows up in the result…

  • 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-05-24T18:15:45+00:00Added an answer on May 24, 2026 at 6:15 pm

    Why not just make this a subquery and join on the appropriate ID?

    eg,

    select a.*, b.extracolumn
    from othertable b
    join ( ... ) a
    on a.ID = b.ID
    

    You’re getting the errors because of the group by in your above query. You shouldn’t have the same problems if you join it, in its entirety, as a subquery.

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

Sidebar

Related Questions

I have a relatively simple form which asks a variety of questions. One of
I have a relatively simple select statement in a VB6 program that I have
I have a relatively simple application which I need to make native Mac OSX
I have a relatively simple query joining two tables. The Where criteria can be
I have a problem with a relatively simple query and the execution plan Access
I have a relatively simple problem. I have a model named Item which I've
I have a (hopefully) a relatively simple question. How do I tell Android which
I have a relatively simple goal: I want to create a Cocoa application which
So I have this relatively simple query to pull a random row based on
I have written a relatively simple Java App Engine application which I would like

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.