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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:48:21+00:00 2026-06-14T07:48:21+00:00

I’m not sure how to ask this question in a way that Google will

  • 0

I’m not sure how to ask this question in a way that Google will understand. I want to left join two tables and have the blank fields filled in. Here’s what I’m working with:

tbl1
| user | date  | usage |
| us1  | 01/12 |  503  |
| us1  | 02/12 |  245  |
| us1  | 03/12 |  465  |
| us2  | 02/12 |  327  |
| us2  | 03/12 |  204  |
| us3  | 02/12 |  156  |

tbl2
| dates | avg_use |
| 01/12 |   345   |
| 02/12 |   426   |
| 03/12 |   502   |

Desired output
| user | date  | usage  |  pct_of_avg  |
| us1  | 01/12 |  503   |     1.45     |
| us1  | 02/12 |  245   |     .58      |
| us1  | 03/12 |  465   |     .93      |
| us2  | 01/12 | (null) |      0       |
| us2  | 02/12 |  327   |     .95      |
| us2  | 03/12 |  204   |     .41      |
| us3  | 01/12 | (null) |      0       |
| us3  | 02/12 |  156   |     .37      |
| us3  | 03/12 | (null) |      0       |

I understand JOINs pretty well, so I’m aware that a typical JOIN will not be able to do this since the data in tbl1.user won’t exist. Is there a way to do this in SQL at all? Bonus points for giving what I’m trying to do a name, because it would help a lot just to know how to Google this 🙂

  • 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-14T07:48:22+00:00Added an answer on June 14, 2026 at 7:48 am

    This should do it:

    SELECT U.user, T2.dates date, T1.usage, T1.usage/T2.avg_use pct_of_avg  
    FROM (SELECT DISTINCT user FROM tbl1) U
    CROSS JOIN tbl2 T2
    LEFT JOIN tbl1 T1
        ON T2.date = T1.date  AND U.user = T1.user
    
    • 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 ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
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

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.