I have to change my question.
I manage to create temp table with data about orders. I am not able to post a screenshot.
Columns are:
rownumber, account, orderposition, ordernnumber, opentime, closetime, modifaytime, symbol
Rows look like this
FIRST ROW
1, 12345, 1552723, 1576459, 2021-04-08 13:02:11,2021-04-08 13:02:11, 2021-04-08 13:02:11,'ELECTRICS'
SECOND ROW
2, 12345, 1552725, 157611, 2021-04-08 13:02:16,2021-04-08 13:02:16, 2021-04-08 13:02:16,'ELECTRICS'
THIRD ROW
..... almost like previous two
FOURTH ROW
4, 12345, 1558854, 1558854, 2021-04-08 13:04:01, 2000-01-01 00:00:00, 2021-04-08 13:04:01, 'ELECTRICS'
and so on.
When order is open closetime is equal to 2000-01-01., orderposition and ordernnumber are equal, when order is closed orderposition and ordernnumber are different, opentime is equal to closetime.
Open and close rows a mixed, row 5 is closed, row 6 is open etc ordered by modifytime.
I need to count rows(orders), but max open orders same day or open at the same time is 5
So if there is 5 orders from yesterday it's fault to open another order until at least one order from yesterday isn't closed and should have some output that will have data about accounts with more then 5 open orders
There are multiple accounts and symbols not only one
I'm new to T-SQL sql and tried everything I know, so I need help with this
"I need to count rows(orders), but max open orders same day or open at the same time is 5"
I am going to guess that you need to count the open orders? You have not actually asked a question.