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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

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