January 27, 2005 at 10:21 am
Hello
I m having a table with following structure and data
Point_Table
BNO int
GNO int
Point int
Data
BNO GNO Point
1 1 6
1 2 8
1 3 3
1 4 10
2 1 1
2 2 2
2 3 4
2 4 6
Now i want to print data like a matrix ie
BID/GID 1 2 3 4
1 6 8 3 10
2 1 2 4 6
3
4
is it possible to write a query for SQL SERVER to get this type of output
January 27, 2005 at 10:46 am
It is possible, but your requirements/specifications are incomplete.
Are there only 4 GNO's, or can there be more ?
Does each BNO *always* have exactly 4 GNO's ?
January 27, 2005 at 10:55 am
If the above questions are affirmative then the solution will be something like this
SELECT bno, MAX (CASE WHEN gno = 1 THEN point) AS 1,
MAX (CASE WHEN gno = 2 THEN point) AS 2,
MAX (CASE WHEN gno = 3 THEN point) AS 3,
MAX (CASE WHEN gno = 4 THEN point) AS 4
FROM Point_Table
Order by bno
the output will be this
bno--1--2--3--4
1----6--8--3--10
2----1--2--4--6
3
4
January 28, 2005 at 10:04 am
No always 4 Gno's its about 27 always both gno and bno r 27
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply