clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2591665 fiddles created (45712 in the last week).

CREATE TABLE [dbo].[line]( [id] [int] NOT NULL, [name] [varchar](255) NOT NULL, [weight] [int] NOT NULL, [turn] [int] NOT NULL, PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], UNIQUE NONCLUSTERED ( [turn] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
 hidden batch(es)


ALTER TABLE [dbo].[line] WITH CHECK ADD CHECK (([weight]>(0)))
 hidden batch(es)


INSERT INTO [dbo].[line] ([id], [name], [weight], [turn]) SELECT 5, 'g', 800, 1 UNION ALL SELECT 3, 'jo', 350, 2 UNION ALL SELECT 6, 'thomas', 400, 3 UNION ALL SELECT 2, 'will', 200, 4 UNION ALL SELECT 4, 'th', 175, 5 UNION ALL SELECT 1, 'james', 100, 6 UNION ALL SELECT TOP 1000 6 + ROW_NUMBER() OVER (ORDER BY (SELECT NULL)), LEFT(NEWID(),3), 1 + CRYPT_GEN_RANDOM(1), 6 + ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM master..spt_values;
1006 rows affected
 hidden batch(es)


set statistics xml on; WITH T1 AS (SELECT *, SUM(Weight) OVER (ORDER BY turn ROWS UNBOUNDED PRECEDING) AS cume_weight FROM [dbo].[line]), T2 AS (SELECT LEAD(cume_weight) OVER (ORDER BY turn) AS next_cume_weight, * FROM T1) SELECT TOP 1 name FROM T2 WHERE next_cume_weight > 1000 OR next_cume_weight IS NULL ORDER BY turn
name
g
Microsoft SQL Server 2005 XML Showplan
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.8" Build="14.0.3015.40"><BatchSequence><Batch><Statements><StmtSimple StatementText="WITH T1&#xd;&#xa; AS (SELECT *,&#xd;&#xa; SUM(Weight) OVER (ORDER BY turn ROWS UNBOUNDED PRECEDING) AS cume_weight&#xd;&#xa; FROM [dbo].[line]),&#xd;&#xa; T2&#xd;&#xa; AS (SELECT LEAD(cume_weight) OVER (ORDER BY turn) AS next_cume_weight,&#xd;&#xa; *&#xd;&#xa; FROM T1)&#xd;&#xa;SELECT TOP 1 name&#xd;&#xa;FROM T2&#xd;&#xa;WHERE next_cume_weight &gt; 1000&#xd;&#xa; OR next_cume_weight IS NULL&#xd;&#xa;ORDER BY turn" StatementId="1" StatementCompId="2" StatementType="SELECT" RetrievedFromCache="true" StatementSubTreeCost="0.0129023" StatementEstRows="1" SecurityPolicyApplied="false" StatementOptmLevel="FULL" QueryHash="0xA1DB0ECE4384D910" QueryPlanHash="0x5128142E8BF9F23C" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" CardinalityEstimationModelVersion="140"><StatementSetOptions QUOTED_IDENTIFIER="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" NUMERIC_ROUNDABORT="false"></StatementSetOptions><QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="NoParallelPlansInDesktopOrExpressEdition" CachedPlanSize="64" CompileTime="0" CompileCPU="0" CompileMemory="376"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="419378" EstimatedPagesCached="26211" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="2182080"></OptimizerHardwareDependentProperties><TraceFlags IsCompileTime="1"><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><TraceFlags IsCompileTime="0"><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><QueryTimeStats ElapsedTime="0" CpuTime="0"></QueryTimeStats><RelOp NodeId="0" PhysicalOp="Top" LogicalOp="Top" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-007" AvgRowSize="138" EstimatedTotalSubtreeCost="0.0129023" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><Top RowCount="0" IsPercent="0" WithTies="0"><TopExpression><ScalarOperator ScalarString="(1)"><Const ConstValue="(1)"></Const></ScalarOperator></TopExpression><RelOp NodeId="1" PhysicalOp="Filter" LogicalOp="Filter" EstimateRows="1" EstimateRowsWithoutRowGoal="302.15" EstimateIO="0" EstimateCPU="0.00088528" AvgRowSize="142" EstimatedTotalSubtreeCost="0.0129022" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><Filter StartupExpression="0"><RelOp NodeId="2" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="0.000631768" AvgRowSize="178" EstimatedTotalSubtreeCost="0.0128992" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1003"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="Expr1003"></ColumnReference><ScalarOperator ScalarString="LAST_VALUE([Expr1002])"><Aggregate Distinct="0" AggType="LAST_VALUE"><ScalarOperator><Identifier><ColumnReference Column="Expr1002"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ScalarOperator ScalarString="ANY([fiddle_6d49463e1ef742ed881ebeb020009d97].[dbo].[line].[name])"><Aggregate Distinct="0" AggType="ANY"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ScalarOperator ScalarString="ANY([fiddle_6d49463e1ef742ed881ebeb020009d97].[dbo].[line].[turn])"><Aggregate Distinct="0" AggType="ANY"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Column="WindowCount1015"></ColumnReference></GroupBy><RelOp NodeId="3" PhysicalOp="Window Spool" LogicalOp="Window Spool" EstimateRows="6.65894" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="0.00221119" AvgRowSize="178" EstimatedTotalSubtreeCost="0.0128972" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1002"></ColumnReference><ColumnReference Column="RowNumber1006"></ColumnReference><ColumnReference Column="WindowCount1015"></ColumnReference><ColumnReference Column="Segment1014"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="3" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><WindowSpool><RelOp NodeId="4" PhysicalOp="Segment" LogicalOp="Segment" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="6.31768e-005" AvgRowSize="178" EstimatedTotalSubtreeCost="0.012889" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1002"></ColumnReference><ColumnReference Column="RowNumber1006"></ColumnReference><ColumnReference Column="TopRowNumber1007"></ColumnReference><ColumnReference Column="BottomRowNumber1008"></ColumnReference><ColumnReference Column="Segment1014"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="4" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><Segment><GroupBy></GroupBy><SegmentColumn><ColumnReference Column="Segment1014"></ColumnReference></SegmentColumn><RelOp NodeId="5" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="0.0001006" AvgRowSize="170" EstimatedTotalSubtreeCost="0.0128888" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1002"></ColumnReference><ColumnReference Column="RowNumber1006"></ColumnReference><ColumnReference Column="TopRowNumber1007"></ColumnReference><ColumnReference Column="BottomRowNumber1008"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="TopRowNumber1007"></ColumnReference><ScalarOperator ScalarString="[RowNumber1006]+(1)"><Arithmetic Operation="ADD"><ScalarOperator><Identifier><ColumnReference Column="RowNumber1006"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(1)"></Const></ScalarOperator></Arithmetic></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="BottomRowNumber1008"></ColumnReference><ScalarOperator ScalarString="[RowNumber1006]+(1)"><Arithmetic Operation="ADD"><ScalarOperator><Identifier><ColumnReference Column="RowNumber1006"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(1)"></Const></ScalarOperator></Arithmetic></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="6" PhysicalOp="Sequence Project" LogicalOp="Compute Scalar" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="8.048e-005" AvgRowSize="154" EstimatedTotalSubtreeCost="0.0128885" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1002"></ColumnReference><ColumnReference Column="RowNumber1006"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="4" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><SequenceProject><DefinedValues><DefinedValue><ColumnReference Column="RowNumber1006"></ColumnReference><ScalarOperator ScalarString="row_number"><Sequence FunctionName="row_number"></Sequence></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="7" PhysicalOp="Segment" LogicalOp="Segment" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="2.012e-005" AvgRowSize="154" EstimatedTotalSubtreeCost="0.0128882" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1002"></ColumnReference><ColumnReference Column="Segment1013"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="4" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><Segment><GroupBy></GroupBy><SegmentColumn><ColumnReference Column="Segment1013"></ColumnReference></SegmentColumn><RelOp NodeId="8" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="0.0001006" AvgRowSize="146" EstimatedTotalSubtreeCost="0.0128881" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1002"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Expr1002"></ColumnReference><ScalarOperator ScalarString="CASE WHEN [Expr1004]=(0) THEN NULL ELSE [Expr1005] END"><IF><Condition><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Column="Expr1004"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(0)"></Const></ScalarOperator></Compare></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="NULL"></Const></ScalarOperator></Then><Else><ScalarOperator><Identifier><ColumnReference Column="Expr1005"></ColumnReference></Identifier></ScalarOperator></Else></IF></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="9" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="0.000631768" AvgRowSize="162" EstimatedTotalSubtreeCost="0.0128878" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Expr1004"></ColumnReference><ColumnReference Column="Expr1005"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="4" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="Expr1004"></ColumnReference><ScalarOperator ScalarString="Count(*)"><Aggregate AggType="countstar" Distinct="0"></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1005"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_6d49463e1ef742ed881ebeb020009d97].[dbo].[line].[weight])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ScalarOperator ScalarString="ANY([fiddle_6d49463e1ef742ed881ebeb020009d97].[dbo].[line].[name])"><Aggregate Distinct="0" AggType="ANY"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ScalarOperator ScalarString="ANY([fiddle_6d49463e1ef742ed881ebeb020009d97].[dbo].[line].[turn])"><Aggregate Distinct="0" AggType="ANY"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Column="WindowCount1012"></ColumnReference></GroupBy><RelOp NodeId="10" PhysicalOp="Window Spool" LogicalOp="Window Spool" EstimateRows="6.65894" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="0.00221119" AvgRowSize="162" EstimatedTotalSubtreeCost="0.0128857" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="RowNumber1009"></ColumnReference><ColumnReference Column="WindowCount1012"></ColumnReference><ColumnReference Column="Segment1011"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="9" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><WindowSpool><RelOp NodeId="11" PhysicalOp="Segment" LogicalOp="Segment" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="6.31768e-005" AvgRowSize="162" EstimatedTotalSubtreeCost="0.0128775" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="RowNumber1009"></ColumnReference><ColumnReference Column="Segment1011"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="6" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><Segment><GroupBy></GroupBy><SegmentColumn><ColumnReference Column="Segment1011"></ColumnReference></SegmentColumn><RelOp NodeId="12" PhysicalOp="Sequence Project" LogicalOp="Compute Scalar" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="8.048e-005" AvgRowSize="154" EstimatedTotalSubtreeCost="0.0128773" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="RowNumber1009"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="6" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><SequenceProject><DefinedValues><DefinedValue><ColumnReference Column="RowNumber1009"></ColumnReference><ScalarOperator ScalarString="row_number"><Sequence FunctionName="row_number"></Sequence></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="13" PhysicalOp="Segment" LogicalOp="Segment" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="2.012e-005" AvgRowSize="154" EstimatedTotalSubtreeCost="0.0128771" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference><ColumnReference Column="Segment1010"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="6" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><Segment><GroupBy></GroupBy><SegmentColumn><ColumnReference Column="Segment1010"></ColumnReference></SegmentColumn><RelOp NodeId="14" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimateIO="0" EstimateCPU="0.00420508" AvgRowSize="146" EstimatedTotalSubtreeCost="0.012877" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="6" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><NestedLoops Optimized="0"><OuterReferences><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="id"></ColumnReference></OuterReferences><RelOp NodeId="15" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="3.32947" EstimateRowsWithoutRowGoal="1006" EstimatedRowsRead="1006" EstimateIO="0.00386574" EstimateCPU="0.0012636" AvgRowSize="15" EstimatedTotalSubtreeCost="0.00328738" TableCardinality="1006" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="id"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="6" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="2" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="6" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="id"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="turn"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Index="[UQ__line__9CF8A217E82E6ED7]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp><RelOp NodeId="17" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="142" EstimatedTotalSubtreeCost="0.00957571" TableCardinality="1006" Parallel="0" EstimateRebinds="3.32616" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="6" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualScans="0" ActualLogicalReads="12" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="6" ActualEndOfScans="0" ActualExecutions="6"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Lookup="1" Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="name"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="weight"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Index="[PK__line__3213E83F0B02A2F8]" TableReferenceId="-1" IndexKind="Clustered" Storage="RowStore"></Object><SeekPredicates><SeekPredicateNew><SeekKeys><Prefix ScanType="EQ"><RangeColumns><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="id"></ColumnReference></RangeColumns><RangeExpressions><ScalarOperator ScalarString="[fiddle_6d49463e1ef742ed881ebeb020009d97].[dbo].[line].[id]"><Identifier><ColumnReference Database="[fiddle_6d49463e1ef742ed881ebeb020009d97]" Schema="[dbo]" Table="[line]" Column="id"></ColumnReference></Identifier></ScalarOperator></RangeExpressions></Prefix></SeekKeys></SeekPredicateNew></SeekPredicates></IndexScan></RelOp></NestedLoops></RelOp></Segment></RelOp></SequenceProject></RelOp></Segment></RelOp></WindowSpool></RelOp></StreamAggregate></RelOp></ComputeScalar></RelOp></Segment></RelOp></SequenceProject></RelOp></ComputeScalar></RelOp></Segment></RelOp></WindowSpool></RelOp></StreamAggregate></RelOp><Predicate><ScalarOperator ScalarString="[Expr1003] IS NULL OR [Expr1003]&gt;(1000)"><Logical Operation="OR"><ScalarOperator><Compare CompareOp="IS"><ScalarOperator><Identifier><ColumnReference Column="Expr1003"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="NULL"></Const></ScalarOperator></Compare></ScalarOperator><ScalarOperator><Compare CompareOp="GT"><ScalarOperator><Identifier><ColumnReference Column="Expr1003"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(1000)"></Const></ScalarOperator></Compare></ScalarOperator></Logical></ScalarOperator></Predicate></Filter></RelOp></Top></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML>
 hidden batch(es)