Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

This challenge has been taken from a forum. The challenge is all about searching the closest number in a collection of numbers. Let’s have a look into the sample data.

TSQL Beginners Challenge 5 - Search the closest number in the series

TSQL Beginners Challenge 5 - Search the closest number in the series

Apr 12 2010 2:45AM by Niladri Biswas   

Introduction

This challenge has been taken from a forum. The challenge is all about searching the closest number in a collection of numbers. Let’s have a look into the sample data.

Sample Data

Numbers
-------
10
12
19
25
25
34
38 

Let’s assume that we need to search the number 24. Here is the expected result.

Expected Results

Closest Number
--------------
25

Rules

  1. The program should run in SQL SERVER 2005+.
  2. Column names should respect the desired output shown.
  3. Must use Ranking Functions.

Sample Script

Use the following script to generate the sample data

DECLARE @T TABLE(Numbers INT)
INSERT INTO @t
SELECT 10 UNION ALL
SELECT 12 UNION ALL
SELECT 19 UNION ALL
SELECT 25 UNION ALL
SELECT 25 UNION ALL
SELECT 34 UNION ALL
SELECT 38

DECLARE @NumberToSearch INT
SET @NumberToSearch = 24

Restrictions

  1. The solution should be a single query that starts with a "SELECT" or “;WITH”.

Notes

Tags:Puzzles, TSQL Beginners Challenge, TC, TSQL Beginners Challenge 5

Niladri Biswas
7 · 21% · 6720
TSQL Beginners Challenge 5 - Search the closest number in the series , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]