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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:54:57+00:00 2026-05-19T13:54:57+00:00

Basically, I want have two separate SQL queries, but I want them to be

  • 0

Basically, I want have two separate SQL queries, but I want them to be displayed in the same result set. However, the first query returns several columns and the second query only returns one column.

If I want the results from the second query to simply be added on as an additional column to the results from the first query, how do I do this?

Query 1:

SELECT cr.COMMUNICATION_ID, cr.CONSUMER_ID, cr.ACTION_LOG_ID, cal.CONSUMER_ID, cal.TIPS_AMOUNT, cal.LAST_MOD_TIME
FROM COMMUNICATION_RELEVANCE AS cr
JOIN consumer_action_log AS cal
ON cr.ACTION_LOG_ID=cal.ACTION_LOG_ID;

QUERY 2:

SELECT AVG(TIPS_AMOUNT) AS AVG_TIPS
FROM CONSUMER_ACTION_LOG
JOIN COMMUNICATION_RELEVANCE
ON CONSUMER_ACTION_LOG.SENDER_CONSUMER_ID=COMMUNICATION_RElEVANCE.consumer_id;

Basically, I want a UNION, but for queries with different number of columns.

  • 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-19T13:54:58+00:00Added an answer on May 19, 2026 at 1:54 pm

    I think you actually want to add one column, not one row as the other answers suggest

    SELECT cr.COMMUNICATION_ID, cr.CONSUMER_ID, cr.ACTION_LOG_ID,
           cal.CONSUMER_ID, cal.TIPS_AMOUNT, cal.LAST_MOD_TIME,
           SINGLETON.AVG_TIPS
    FROM COMMUNICATION_RELEVANCE AS cr
    JOIN consumer_action_log AS cal ON cr.ACTION_LOG_ID=cal.ACTION_LOG_ID
    CROSS JOIN
    (
        SELECT AVG(TIPS_AMOUNT) AS AVG_TIPS
        FROM CONSUMER_ACTION_LOG
        JOIN COMMUNICATION_RELEVANCE
        ON CONSUMER_ACTION_LOG.SENDER_CONSUMER_ID=COMMUNICATION_RElEVANCE.consumer_id
    ) SINGLETON
    

    The trick is that you join to the query that produces the single row, single column AVG value.

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

Sidebar

Related Questions

So I basically want to have a static method in my AR class to
Basically I want to have our installer also install the .NET framework and any
I have a 2-dimensional array of objects and I basically want to databind each
I have a bit of a problem with user controls. Basically what I want
Basically I want to know how to set center alignment for a cell using
We have two databases, in two separate locations. One of the databases resides in
I want to JOIN two table. Have no problem with that. I have problem
I basically want to use link_to to link to the index method of a
I basically want to do this: grep 'example.com' www_log > example.com.YYYY-MM-DD-H:i:S.log ...with of course
This is an incredibly simple question (I'm new to Python). I basically want a

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.