SELECT * FROM depdetail WHERE postingdate = '2016-01-07' AND LEFT(store,4) = @comp_code
This works.
There's another table called company.
The company table has a column called comp_group, which can be blank or contain the code of another row in the table (comp_code)
It's a way of grouping related companies for reporting.
In addition to the rows pulled above, I'd like the query to pull any rows of related companies.
I can do it in the .NET app by looping, but I'd like to do it with a query if possible.
Any ideas?
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.