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
Answer Posted / 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 View All Answers
Difference between DELETE and TRUNCATE?
What is difference between after and before?
What is a covered index?
How many types of built in functions are there in sql server 2012?
Why I am getting "the microsoft .net framework 2.0 in not installed" message?
What does indexation mean?
How to select some specific columns from a table in a query in ms sql server?
What is executereader?
What do you mean by stored techniques? How would we use it?
hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.
What is a livelock?
Explain transaction server explicit transaction?
What is rank function?
What is a deadlock and what is a live lock?
Explain difference between control flow and data flow?