Getting Started with Adobe After Effects - Part 6: Motion Blur
First Time? You can support us by signing up. It takes only 5 seconds. Click here to sign up. If you already have an account, click here to login.

TSQL Challenge 50 - Extract a subset of the input data by using only a limited set of SQL keywords

Are you a minimalist? Do you like to do more with less? Do you enjoy being in a straight jacket while solving problems? This challenge has a bit of all of these. So dig in and keep that button labeled ‘patience’ handy.

The purpose of this challenge is to test your query writing skills with a limited set of TSQL keywords. This will certainly be a good test of your TSQL creativity. The query must sort alphabetically these names and extract odd lines, with name and position.

Izenda Reports is the official sponsor of this challenge. Izenda Reports and Dashboards is the easiest and fastest way to create ad hoc reports from SQL Server data bases.

Sample Data

Name Table

  
 Name
--------
Allan
Allan
John
Vick
Joe
Allan
Joe
Vick
Peter
Allan
Joe
Vick
Peter
John
Mark
Vick

Expected Results

Name  Position 
----- --------
Allan        1 
Allan        3 
Joe          5 
Joe          7 
John         9 
Peter       11 
Vick        13 
Vick        15 

Rules

  1. You should use only the following keywords: count, distinct, from, order by, select, union, where; and as a special treat we’ll add the word ‘as’.
  2. The solution must be able to handle a table with up to 100,000 rows
  3. Operators allowed: = , < , > , + (plus) , * (multiply) , <= , % (modulo) ,>= , ( , )
  4. Thus 'not' is not allowed, 'union all' is not allowed and 'where ... in (...)' is not allowed and the logical operators 'and' and 'or' are not allowed.

Sample Script

Use the TSQL Script given below to generate the source table and fill them with sample data.

SET NOCOUNT ON
IF OBJECT_ID('TC50','U') IS NOT NULL BEGIN
	DROP TABLE TC50
END

CREATE TABLE TC50 (
	Name VARCHAR(8)
)

INSERT INTO TC50(Name)  values('Allan') 
INSERT INTO TC50(Name)  values('Allan') 
INSERT INTO TC50(Name)  values('John') 
INSERT INTO TC50(Name)  values('Vick') 
INSERT INTO TC50(Name)  values('Joe') 
INSERT INTO TC50(Name)  values('Allan') 
INSERT INTO TC50(Name)  values('Joe') 
INSERT INTO TC50(Name)  values('Vick') 
INSERT INTO TC50(Name)  values('Peter') 
INSERT INTO TC50(Name)  values('Allan') 
INSERT INTO TC50(Name)  values('Joe') 
INSERT INTO TC50(Name)  values('Vick') 
INSERT INTO TC50(Name)  values('Peter') 
INSERT INTO TC50(Name)  values('John') 
INSERT INTO TC50(Name)  values('Mark') 
INSERT INTO TC50(Name)  values('Vick')

SELECT * FROM tc50

Restrictions

  1. The solution should be a single query that starts with "SELECT".

Notes

  1. Read the Submission Guidelines and make sure that your solution follows them.
  2. If you would like to use a Tally Table, you can use the script given here. Your solution should not include the script to create and populate the tally table. You can assume that the tally table will be available in the database where the evaluation team will run your Code.
Try Izenda Reports, The #1 Ad Hoc Reporting Solution for ASP.NET.

Izenda's Reports, Dashboards and Maps have been integrated into thousands ASP.NET applications allowing users to create and customize their own reports over a browser.  Users can create dashboards, charts, pivots, schedule reports and manipulate filters without going back to development or IT.

Find out why our deverlopers are amazed at how quickly they can embed Izenda Reports while fully supporting their security and branding. 


petrut
212 · 1% · 219
Submit a Solution
Previous Challenge
Next Challenge
1
Liked
26
Comments
99
Solutions



Submit

TSQL Challenge 50 - Extract a subset of the input data by using only a limited set of SQL keywords

Managed Windows Shared Hosting by OrcsWeb

Copyright © Rivera Informatic Private Ltd.