I am attempting to display a column from one of 3 tables I have in my query, but I can't seem to figure out how to get it to work properly. No matter what I try, it doesn't seem to work. It seems easy, but maybe I am missing something really simple. Here is what I have:
SELECT hpg.id_number,
hpg.id_description,
COUNT (hdd.number_of_games) games,
SUM (NVL (price, 0)) total,
SUM (number_of_food) food
--I tried adding column here, but nothing seemed to work
FROM (SELECT number_of_games, price, prints
FROM (hopeful_dog_hops)
WHERE status = 'Done') hdd,
(SELECT SUM (number_of_food) number_of_food, number_of_games
FROM hot_digity_dog
GROUP BY number_of_games) hdd1,
(SELECT id_description, sort_types, id_number
FROM (hot_pick_games)
WHERE disabled = 'TRUE' AND viewable_type = 'OK') hpg
WHERE hdd.prints(+) = hpg.id_number
AND hdd.number_of_games = hdd1.number_of_games
GROUP BY hpg.id_description, hpg.id_number, sort_types
ORDER BY sort_types
This huge query displays these columns:
ID_NUMBER ID_DESCRIPTION GAMES TOTAL FOOD
I need to add one more column:
TEST
from the hot_digity_dog table.
Don't worry so much about the names of everything, but I just need to figure out how exactly I can get another column to display in the query. I tried adding TEST to the first SELECT statement, but it gave me an error saying: "TEST:invalid identifier."
I know the query works (without the added TEST part, so it can't be an error in the query). It has to be something with the new added part.
Any help would be greatly appreciated. Thanks in advance.
Here is the query with the new column:
SELECT hpg.id_number,
hpg.id_description,
COUNT (hdd.number_of_games) games,
SUM (NVL (price, 0)) total,
SUM (number_of_food) food,
hdd.TEST
FROM (SELECT number_of_games, price, prints
FROM (hopeful_dog_hops)
WHERE status = 'Done') hdd,
(SELECT SUM (number_of_food) number_of_food, number_of_games
FROM hot_digity_dog
GROUP BY number_of_games) hdd1,
(SELECT id_description, sort_types, id_number
FROM (hot_pick_games)
WHERE disabled = 'TRUE' AND viewable_type = 'OK') hpg
WHERE hdd.prints(+) = hpg.id_number
AND hdd.number_of_games = hdd1.number_of_games
GROUP BY hpg.id_description, hpg.id_number, sort_types
ORDER BY sort_types
And here is what the column headers should look like:
ID_NUMBER ID_DESCRIPTION GAMES TOTAL FOOD TEST
number_of_games, price, printsand I suspect it will work.