Advertisement
Guest User

Untitled

a guest
Nov 14th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.64 KB | None | 0 0
  1. SELECT TOP 20 *
  2.  FROM (SELECT [t1].[ID] AS [t1_ID],
  3.  [t1].[_stamp] AS [t1__stamp],
  4.  [t1].[Status] AS [t1_Status],
  5.  [t2].[Name] AS [t2_Name],
  6.  [t1].[NotificationNumber] AS [t1_NotificationNumber],
  7.  [t1].[OrderName] AS [t1_OrderName],
  8.  [t1].[Lot] AS [t1_Lot],
  9.  [t3].[StartPrice] AS [t3_StartPrice],
  10.  [t1].[PlacerInfo] AS [t1_PlacerInfo],
  11.  [t4].[FullName] AS [t4_FullName],
  12.  [t1].[PublishedDate] AS [t1_PublishedDate],
  13.  [t1].[p1Date] AS [t1_p1Date],
  14.  [t1].[p2Date] AS [t1_p2Date],
  15.  [t1].[Stage] AS [t1_Stage],
  16.  [t5].[Name] AS [t5_Name],
  17.  [t1].[LastChangeDate] AS [t1_LastChangeDate],
  18.  ROW_NUMBER() OVER ( ORDER BY t1.[ID] DESC)  as ROW_NUMBER
  19.  FROM [NotificationZK] t1 WITH(NOLOCK)
  20.  LEFT
  21.  JOIN [NotificationZKStagees] t5 WITH(NOLOCK) ON t5.[ID] = t1.[Stage]
  22.  LEFT
  23.  JOIN [OrganizationInfos] t4 WITH(NOLOCK) ON t4.[ID] = t1.[PlacerInfo]
  24.  LEFT
  25.  JOIN [NotificationZKLots] t3 WITH(NOLOCK) ON t3.[ID] = t1.[Lot]
  26.  LEFT
  27.  JOIN [NotificationZKStatuses] t2 WITH(NOLOCK) ON t2.[ID] = t1.[Status]
  28.  WHERE (t1.[IsGroupNotificationZK] = 0)
  29.    AND (t1.[IsTemplate] = 0)
  30.    AND ((t1.[ZKType] = 1)
  31.    OR (t1.[ZKType] = 3) )
  32.    AND ((t1.[IsPrivate] = 0)
  33.    OR (t1.[Placer] = 586003)
  34.    OR (t1.[Initiator] = 586003)
  35.    OR (EXISTS (SELECT t6.[NotificationZK]
  36.  FROM [CustomerRequirementZK] t6
  37.  WHERE (t6.[NotificationZK] = t1.[ID])
  38.    AND (t6.[Customer] = 586003) )) )
  39.    AND ((t1.[Placer] = 586003)
  40.    OR (t1.[Initiator] = 586003)
  41.    OR (EXISTS (SELECT t7.[NotificationZK]
  42.  FROM [CustomerRequirementZK] t7
  43.  WHERE (t7.[NotificationZK] = t1.[ID])
  44.    AND (t7.[Customer] = 586003) )) )
  45.    AND (t1.[IsLot] = 0) ) as [QueryRN]
  46.  WHERE ROW_NUMBER BETWEEN 1
  47.    AND 20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement