FIRST_VALUE Analytic Function in SQL Server - #3

Pubblicato il: 22 giugno 2020
sul canale di: Everyday Be Coding
2,529
23

#SQLServer #FIRSTVALUE #SQLAnalytics #DataAnalysis #TSQL #SQLFunctions #DataScience #Database #SQLQuery #SQLTips #DataEngineering #BigData #Analytics #SQLServer2019 #SQLServer2022 #TechTips #Programming #DataVisualization #BusinessIntelligence #sqlperformance

Playlist -    • CUME_DIST analytic function in SQL Se...  
------------------------------------------------------------------------------------------
CUME_DIST() -    • CUME_DIST analytic function in SQL Se...  
PERCENT_RANK() -    • PERCENT_RANK analytic function in SQL...  
FIRST_VALUE() -    • FIRST_VALUE Analytic Function in SQL ...  
LAST_VALUE() -    • LAST_VALUE Analytic Functions in SQL ...  
LEAD() -    • LED Analytic Function in SQL  - #5 #S...  
LAG() -    • LAG Analytic Function in SQL Server -...  
PERCENTILE_CONT() -    • PERCENTILE_CONT analytic function in ...  
PERCENTILE_DISC() -    • PERCENTILE DISC analytic function in ...  
------------------------------------------------------------------------------------------
QUERY SOLVE -
1. What is analytic functions in SQL Server?
2. What is FIRST_VALUE analytic functions in SQL Server?
3. Syntax of FIRST_VALUE analytic functions?
4. What is partition by clause in SQL Server?
5. What is Order by clause in SQL Server?
6. Default parameters of FIRST_VALUE analytic functions in SQL Server?

FIRST_VALUE()
-------------------------
The first_value function retrieves the first value from the specified column for the records that have been sorted using the ORDER BY clause.
Syntax :
FIRST_VALUE ( [scalar_expression ] )
OVER ( [ partition_by_clause ] order_by_clause [ rows_range_clause ] )

QUERY:
SELECT [Name],
Make,
Model,
Price,
[Type],
FIRST_VALUE (Name) over (PARTITION BY [TYPE] ORDER BY price ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as FIRST_VALUE
--FIRST_VALUE (Name) over (ORDER BY price DESC) as FIRST_VALUE
FROM [DbSample].[dbo].[Bikes]

partition_by_clause divides the result set produced by the FROM clause into partitions to which the function is applied. If not specified, the function treats all rows of the query result set as a single group.

order_by_clause determines the logical order in which the operation is performed. order_by_clause is required.

rows_range_clause further limits the rows within the partition by specifying start and end points.


In questa pagina del sito puoi guardare il video online FIRST_VALUE Analytic Function in SQL Server - #3 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Everyday Be Coding 22 giugno 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,529 volte e gli è piaciuto 23 spettatori. Buona visione!