Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide results if all values in columns are zero 1

Status
Not open for further replies.
May 12, 2002
7
0
0
CA
Hello,
I'm new to Access. I have 5 queries linked together by a table to come up with a consolidated result.
I get the following results (I've made to modifications so it'll be easier to follow onscreen).
If I do not want to show COMCT since it has all Zeros in the column values, how would I go about doing that? I'm not too familiar with SQL. Thanks in advance.

SourceX AX BX CX DX EX
BARON 0 55 0 123 0
CABLE 2 0 -1135 0 0
COMCT 0 0 0 0 0

Sample SQL code:
SELECT Source.csource, [Query1].CountOfcsource, [Query2].CountOfcsource, [Query3].SumOfntotal, [Query4].CountOfMinOfdsold, [Query5].SumOfntotal
FROM [Query2] RIGHT JOIN ([Query5] RIGHT JOIN ([Query4] RIGHT JOIN ([Query1] RIGHT JOIN ([Query3] RIGHT JOIN Source ON [Query3].csource = Table1.csource) ON [Query1].csource = Table1.csource) ON [Query4].csource = Table1.csource) ON [Query5].csource = Table1.csource) ON [Query2].csource = Table1.csource
GROUP BY Table1.csource, [Query1].CountOfcsource, [Query2].CountOfcsource, [Query3].SumOfntotal, [Query4].CountOfMinOfdsold, [Query5].SumOfntotal;
 
I'm not sure if it's only "COMCT" that has the problem (i.e. all zeros) or if you want to eliminate all rows that that are all zeros. If it's just COMCT then
[blue][tt]
SELECT Source.csource, [Query1].CountOfcsource, [Query2].CountOfcsource, [Query3].SumOfntotal, [Query4].CountOfMinOfdsold, [Query5].SumOfntotal
FROM [Query2] RIGHT JOIN ([Query5] RIGHT JOIN ([Query4] RIGHT JOIN ([Query1] RIGHT JOIN ([Query3] RIGHT JOIN Source ON [Query3].csource = Table1.csource) ON [Query1].csource = Table1.csource) ON [Query4].csource = Table1.csource) ON [Query5].csource = Table1.csource) ON [Query2].csource = Table1.csource

WHERE Source.csource <> "COMCT"

GROUP BY Table1.csource, [Query1].CountOfcsource, [Query2].CountOfcsource, [Query3].SumOfntotal, [Query4].CountOfMinOfdsold, [Query5].SumOfntotal
[/tt][/blue]
If it's all "all zeros" rows
[blue][tt]
SELECT Source.csource, [Query1].CountOfcsource, [Query2].CountOfcsource, [Query3].SumOfntotal, [Query4].CountOfMinOfdsold, [Query5].SumOfntotal
FROM [Query2] RIGHT JOIN ([Query5] RIGHT JOIN ([Query4] RIGHT JOIN ([Query1] RIGHT JOIN ([Query3] RIGHT JOIN Source ON [Query3].csource = Table1.csource) ON [Query1].csource = Table1.csource) ON [Query4].csource = Table1.csource) ON [Query5].csource = Table1.csource) ON [Query2].csource = Table1.csource

WHERE [Query1].CountOfcsource <> 0
OR [Query2].CountOfcsource <> 0
OR [Query3].SumOfntotal <> 0
OR [Query4].CountOfMinOfdsold <> 0
OR [Query5].SumOfntotal <> 0

GROUP BY Table1.csource, [Query1].CountOfcsource, [Query2].CountOfcsource, [Query3].SumOfntotal, [Query4].CountOfMinOfdsold, [Query5].SumOfntotal
[/tt][/blue]

 
Thank you, that worked perfectly. And thank you for the quick answer!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top