mainsearch| stats count(_raw) as Cou by hour
|join hour [ subsearch| head -$Cou$ ]
Above mentioned command is not working, as main search values can be used as values in subsearch but unable to use it under a command. Any suggestions?
The question is not whether you can pass main search result value into subsearch, but what is it you are trying to perform. There are many ways to implement anything in any general-purpose language such as SPL. You already know the method proposed in the OP doesn't do what you wanted. So, start by explaining your data, your logic, and your expected output. (This should be the general formula when posing a question.)
Starting from data and logic is even more important because join command is often the least efficient way to achieve anything. Most of the time, join can be avoided.
Thank you @yuanliu for feedback. I have created a new conversation based on your suggestions.
https://community.splunk.com/t5/Splunk-Search/how-to-get-90-of-max-execution-time/m-p/625167#M217321