Saturday, December 30, 2017

tsql How search first position on SQL

tsql How search first position on SQL



I have a problem, I can not find the price status in my table, for example: I have the table:

  ProdID InstID APY C3M2.5K 11920 0.3 C3M2.5K 11246 0.25 C3M2.5 of 11626 0.25 C3M2.5K 12081 0.15 C3M2.5K 11224 0.05 C3M2.5K 11311 0.05 C3M2.5K 11460 0.05 C3M2.5K 11164 0.03 C3M2.5 of 11394 0.01  

Code:

 from  select * from table where APY = 0.05  

select me Required that will be the display:
Calculation (APY) - this is: 9
APY in the first place - this is: 5
Thank you for your help.

You can use this query:

  In the form of CTE (choose Fiction = (Select number (*) FROM dbo.TableName), Pos = ROW_NUMBER () Over (based on ID), ProdID, InstID, APY from dbo.TableName) SELECT TOP 1 Position of API = 0.05  

Demo:



go to link download
download
alternative link download

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.