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


Upload Image Close it
Select File

This challenge is all about counting the number of occurrence of characters in a string using a SET based query. The task is to list all the characters and count of that character within the given string.

TSQL Beginners Challenge 14 - Count the number of occurrence of characters in the string

TSQL Beginners Challenge 14 - Count the number of occurrence of characters in the string

Aug 16 2010 2:00AM by Niladri Biswas   

Introduction

This challenge is all about counting the number of occurrence of characters in a string using a SET based query. The task is to list all the characters and count of that character within the given string.

Sample Data

Data
----
12
xx

Expected Results

Data Chars NumberOfOccurance
---- ----- -------------------
12	 1	   1 appears (1) times
12	 2	   2 appears (1) times
xx	 x	   x appears (2) times

Rules

  1. Results must be sorted in ascending order of Data and then by Character.
  2. The output should be in the same way as it has been shown.

Sample Script

Use the following scripts to generate the sample data for this challenge.

DECLARE @T TABLE(Data VARCHAR(MAX))
INSERT INTO @T
SELECT '12' UNION ALL
SELECT 'xx' 
SELECT * FROM @T

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 14

Niladri Biswas
7 · 21% · 6710
TSQL Beginners Challenge 14 - Count the number of occurrence of characters in the string , 5.0 out of 5 based on 0 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]