Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT TOP 20 *
- FROM (SELECT [t1].[ID] AS [t1_ID],
- [t1].[_stamp] AS [t1__stamp],
- [t1].[Status] AS [t1_Status],
- [t2].[Name] AS [t2_Name],
- [t1].[NotificationNumber] AS [t1_NotificationNumber],
- [t1].[OrderName] AS [t1_OrderName],
- [t1].[Lot] AS [t1_Lot],
- [t3].[StartPrice] AS [t3_StartPrice],
- [t1].[PlacerInfo] AS [t1_PlacerInfo],
- [t4].[FullName] AS [t4_FullName],
- [t1].[PublishedDate] AS [t1_PublishedDate],
- [t1].[p1Date] AS [t1_p1Date],
- [t1].[p2Date] AS [t1_p2Date],
- [t1].[Stage] AS [t1_Stage],
- [t5].[Name] AS [t5_Name],
- [t1].[LastChangeDate] AS [t1_LastChangeDate],
- ROW_NUMBER() OVER ( ORDER BY t1.[ID] DESC) as ROW_NUMBER
- FROM [NotificationZK] t1 WITH(NOLOCK)
- LEFT
- JOIN [NotificationZKStagees] t5 WITH(NOLOCK) ON t5.[ID] = t1.[Stage]
- LEFT
- JOIN [OrganizationInfos] t4 WITH(NOLOCK) ON t4.[ID] = t1.[PlacerInfo]
- LEFT
- JOIN [NotificationZKLots] t3 WITH(NOLOCK) ON t3.[ID] = t1.[Lot]
- LEFT
- JOIN [NotificationZKStatuses] t2 WITH(NOLOCK) ON t2.[ID] = t1.[Status]
- WHERE (t1.[IsGroupNotificationZK] = 0)
- AND (t1.[IsTemplate] = 0)
- AND ((t1.[ZKType] = 1)
- OR (t1.[ZKType] = 3) )
- AND ((t1.[IsPrivate] = 0)
- OR (t1.[Placer] = 586003)
- OR (t1.[Initiator] = 586003)
- OR (EXISTS (SELECT t6.[NotificationZK]
- FROM [CustomerRequirementZK] t6
- WHERE (t6.[NotificationZK] = t1.[ID])
- AND (t6.[Customer] = 586003) )) )
- AND ((t1.[Placer] = 586003)
- OR (t1.[Initiator] = 586003)
- OR (EXISTS (SELECT t7.[NotificationZK]
- FROM [CustomerRequirementZK] t7
- WHERE (t7.[NotificationZK] = t1.[ID])
- AND (t7.[Customer] = 586003) )) )
- AND (t1.[IsLot] = 0) ) as [QueryRN]
- WHERE ROW_NUMBER BETWEEN 1
- AND 20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement