Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


One table Test with single column. These are the values in
the table
a
b
c
d
e
f
g
h
I need a query (without using any variable) with output as -
a b c
d e f
g h



One table Test with single column. These are the values in the table a b c d e f g h I ne..

Answer / gopi muluka

Check this

DECLARE @Character TABLE
(
Ch VARCHAR(50)
)

INSERT INTO @Character
SELECT 'a' UNION
SELECT 'b' UNION
SELECT 'c' UNION
SELECT 'd' UNION
SELECT 'e' UNION
SELECT 'f' UNION
SELECT 'g' UNION
SELECT 'h' UNION
SELECT 'i' UNION
SELECT 'j' UNION
SELECT 'k' UNION
SELECT NULL

SELECT A.Ch,B.Ch,MAX(C.Ch)
FROM @Character A
CROSS JOIN @Character B
CROSS JOIN @Character C
WHERE ASCII(A.Ch)+1=ASCII(B.Ch) AND ASCII(A.Ch)% 3=1
AND ASCII(B.Ch)+1=ISNULL(ASCII(C.Ch),ASCII(B.Ch)+1) AND
ASCII(B.Ch)% 3=2
GROUP BY A.Ch,B.Ch

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Do you know what are acid properties of transaction?

0 Answers  


Explain the advantages of merge replication?

0 Answers  


You are doing log shipping due to some reasons it is failing. How you will proceed from there

0 Answers  


What is the difference between system objects and user objects?

0 Answers   HCL,


How to check what was the last restore transaction LSN on Log-Shipping and Mirroring when we doesn't have a Monitor server and Witness server?

2 Answers   IBM,


What is clustered vs nonclustered index?

0 Answers  


How to avoid cursors?

3 Answers   CarrizalSoft Technologies, HP,


What are the pre-defined functions in the sql server?

0 Answers  


What is the difference between seek predicate and predicate?

0 Answers  


How do you test your database? : sql server database administration

0 Answers  


Where can you add custom error messages to sql server?

0 Answers  


What are the advantages of stored procedure in sql server?

0 Answers  


Categories