Created
September 13, 2021 13:12
-
-
Save AlBannaTechno/360322e358f6bb0db22ca4b56311c17b to your computer and use it in GitHub Desktop.
eXtra_CustomerStatus_seed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insert into CustomerStatus (CustomerId, CreationDate, CompletedRequestsCount, OperationSystemType, DeviceId, Registered, | |
ModifiedDate) | |
select distinct cus.Id as CustomerId, | |
cus.CreationDate as CreationDate, | |
( | |
select Count(prs1.Id) | |
from ServiceRequests as prs1 | |
where prs1.CustomerId = cus.Id AND prs1.Status = 2 | |
) | |
as CompletedRequestsCount, | |
-- If not registered in the db for any reason we will assume it is android | |
ISNULL(logs.OSTypeId, 1) as OperationSystemType, | |
logs.MobileSerialNumber as DeviceId, | |
1, | |
NULL | |
from Customers as cus | |
left outer join Logs as logs on logs.CustomerId = cus.Id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment