I have this table:
The 2 important columns here are domainid and Soldtickets.
Soldtickets show how many tickets were sold today.
I make a call to my server and it tells me that I made the call at "2016-03-30 14:18:01.4130000" and that 0 tickets have been sold for the Domain with DomainId 53.
I am trying to figure out how I can find the difference.
I call the server every two minutes and I get data. I want to check the data that I have got the last 15 minutes and see if soldtickets has changes and how much.
0 Tickets Sold
5 Tickets Sold(5 tickest total for today)
5 Tickets Sold ( same as before, NO change)
I want to know how many were sold the last 15 minutes. In this case it would be 5 tickets but what if at
2016-03-30 14:44:01.4130000 I get back that I have sold a total of 7 tickets for today, then the difference for the last 15 minutes is 2 tickets.
So far I can get the inserts of the last 15 minutes like so:
DECLARE @LatestFifteenMinTickets TABLE ( DomainId bigint, SoldTickets bigint ) DECLARE @FifteenMinDate datetime2 SELECT @FifteenMinDate = DATEADD(minute, -15, GETDATE()) INSERT INTO @LatestFifteenMinTickets(DomainId,SoldTickets) SELECT DomainId, SoldTickets FROM DomainDetailDataHistory WHERE [Date] > @FifteenMinDate
I have tried a few scenarios but I honestly don't know how to conntinue.
How can I do this?
Lets say If i get back that I have sold 0 tickets today at 13:00. And the next 15 minutes I get 15 inserts where soldtickets is also 0. the diffirence here is nothing since 0-0 = 0 Which means I have sold 0 tickets the last 15 minutes AND sold 0 tickets for the entire day (so far). But at 14:00 I get back info from server that 10 tickets are sold. The next 15 minutesI keep getting sold tickets = 10 which means that the last 15 min i have sold 0 tickets but for the entire day i have sold 10 tickets –
I Need to check the soldtickets columnt for every unique DomainId and see if there is any difference to the most current one. If there Is i want to know what the difference is in numbers