Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. CREATE VIEW [dbo].[LatestDeviceLocation]
  2. AS
  3. SELECT DISTINCT t.Imei, t.Accuracy, t.UserId, t.Lat, t.Lng, t.Timestamp
  4. FROM (SELECT Imei, MAX(Timestamp) AS latest
  5. FROM dbo.DeviceLocation
  6. GROUP BY Imei) AS m INNER JOIN
  7. dbo.DeviceLocation AS t ON t.Imei = m.Imei AND t.Timestamp = m.latest
  8. GO
  9.  
  10. /****** Object: Index [GangHeatMapIndex] Script Date: 02/26/2015 22:38:38 ******/
  11. CREATE NONCLUSTERED INDEX [GangHeatMapIndex] ON [dbo].[DeviceLocation]
  12. (
  13. [UserId] ASC,
  14. [Timestamp] ASC,
  15. [Imei] ASC
  16. )
  17. INCLUDE ( [DeviceLocationId],
  18. [Accuracy],
  19. [Lat],
  20. [Lng]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  21. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement