Subselect not working

sheetspread

Well-known Member
Joined
Sep 19, 2005
Messages
5,160
In the TVShows table I have the fields TVShow, Characters, and Age

In query 1 I have the same table with an extra column holding the subselect expression:

Expr1: (select sum(Age) from TVShows where TVShow = x.TVShow)

That works, I get the sum of ages for each show.


However, I'd like to create an independent table (called CertainTVShows) with a TVShow field where I enter the name of shows and write another query with a similar subselect that totals the ages from the original TVShows table that correspond to the shows I've entered in the CertainTVShows table. I thought it was just as simple as adding another:

Expr1: (select sum(Age) from TVShows where TVShow = x.TVShow) but it's not. I get the "Enter Parameter Value" x.TVShow question box and kind of understand why. The query won't match the TVShow fields from the different tables. How do I modify this expression to get results?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If what I said above is too unclear, what does the last part of:

Expr1: (select sum(Age) from TVShows where TVShow = x.TVShow)

actually mean? i.e., where TVShow = x.TVShow. Can it take whatever tv show is written in that field and match it to values in another table? I tried something similar with Dsum and couldn't get it to work either, but Giacomo says the subselect is better for queries and it looks that way, though so far I'm stuck.
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top