Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.70 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()
  19.                  OVER (
  20.                    ORDER BY t1.[id] DESC) AS ROW_NUMBER
  21.         FROM   [notificationzk] t1 WITH(nolock)
  22.                LEFT JOIN [notificationzkstagees] t5 WITH(nolock)
  23.                       ON t5.[id] = t1.[stage]
  24.                LEFT JOIN [organizationinfos] t4 WITH(nolock)
  25.                       ON t4.[id] = t1.[placerinfo]
  26.                LEFT JOIN [notificationzklots] t3 WITH(nolock)
  27.                       ON t3.[id] = t1.[lot]
  28.                LEFT JOIN [notificationzkstatuses] t2 WITH(nolock)
  29.                       ON t2.[id] = t1.[status]
  30.         WHERE  ( t1.[isgroupnotificationzk] = false )
  31.                AND ( t1.[istemplate] = false )
  32.                AND ( ( t1.[zktype] = 1 )
  33.                       OR ( t1.[zktype] = 3 ) )
  34.                AND ( ( t1.[isprivate] = false )
  35.                       OR ( t1.[placer] = 586003 )
  36.                       OR ( t1.[initiator] = 586003 )
  37.                       OR ( EXISTS (SELECT t6.[notificationzk]
  38.                                    FROM   [customerrequirementzk] t6
  39.                                    WHERE  ( t6.[notificationzk] = t1.[id] )
  40.                                           AND ( t6.[customer] = 586003 )) ) )
  41.                AND ( ( t1.[placer] = 586003 )
  42.                       OR ( t1.[initiator] = 586003 )
  43.                       OR ( EXISTS (SELECT t7.[notificationzk]
  44.                                    FROM   [customerrequirementzk] t7
  45.                                    WHERE  ( t7.[notificationzk] = t1.[id] )
  46.                                           AND ( t7.[customer] = 586003 )) ) )
  47.                AND ( t1.[islot] = false )) AS [QueryRN]
  48. WHERE  row_number BETWEEN 1 AND 20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement