all groups > sql server programming > november 2003 >
You're in the

sql server programming

group:

Writing a query


Writing a query AVK.Sanjay
11/26/2003 11:06:12 PM
sql server programming:
Hi Folks
Can any one answe me the following questions
How to print the records using a SQL in the following ways
1. The SQL has to print the out put like this

2
33
444
5555
2. The SQL has to print the out put records vertically like thi
the normal query return the records like thi
1 2 3
I want this in this wa




Re: Writing a query David Portas
11/27/2003 8:14:15 AM
Does this help? Without DDL and sample data it's difficult to know exactly
what your requirements are.

CREATE TABLE Sometable (a INTEGER, b INTEGER, c INTEGER, d INTEGER, e
INTEGER, PRIMARY KEY (a,b,c,d,e))

INSERT INTO Sometable VALUES (1,2,3,4,5)

SELECT REPLICATE(CAST(x AS CHAR(1)),x)
FROM
(SELECT a
FROM Sometable
UNION ALL
SELECT b
FROM Sometable
UNION ALL
SELECT c
FROM Sometable
UNION ALL
SELECT d
FROM Sometable
UNION ALL
SELECT e
FROM Sometable
) AS X(x)

SELECT a
FROM Sometable
UNION ALL
SELECT b
FROM Sometable
UNION ALL
SELECT c
FROM Sometable
UNION ALL
SELECT d
FROM Sometable
UNION ALL
SELECT e
FROM Sometable

If you need more help please post DDL and sample data (CREATE and INSERT
statements as above).

--
David Portas
------------
Please reply only to the newsgroup
--

Re: Writing a query Roji. P. Thomas
11/27/2003 1:39:08 PM
Doesnt seems to make sense ;)

Its fun to do such a thing in C++, but SQL

Whats the requirement?


--
Roji. P. Thomas
SQL Server Programmer ;)
________________________
[quoted text, click to view]

Re: Writing a query realgz
11/27/2003 3:37:52 PM
1.
declare @tmp int
set @tmp=1
while @tmp<=100
begin
print ( REPLICATE(@tmp,@tmp))
set @tmp=@tmp+1
end
2.Sorry i can't catch you.
An Example table will be helpful

AddThis Social Bookmark Button