Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 1st, 2003, 03:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: abu dbabi, , United Arab Emirates.
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query Result

table data
-----------
FromNode ToNode Volume
10011 10010 1353
10011 10012 47
10011 10018 243
10011 10012 330
10011 10014 377
10011 10016 976
10011 10018 310
10012 2755 1586
......

I have query like this.

select
case BOND when 'IP-1' then volume end as [IP-1],
case BOND when 'IP-9' then volume end as [IP-9],
case BOND when 'IP-12' then volume end as [IP-12],
case BOND when 'IP-41' then volume end as [IP-41],
case BOND when 'SBU' then volume end as SBU,
case BOND when 'SBL' then volume end as SBL,
case BOND when 'SBT' then volume end as SBT,
case BOND when 'SBR' then volume end as SBR
from
(select fromnode,tonode,volume,substring(fromnode,3,2) IP,
fromnode % 10 fromnode2, tonode % 10 tonode2,
case
when substring(fromnode,3,2)=01 then 'IP-1'
when substring(fromnode,3,2)=09 then 'IP-9'
when substring(fromnode,3,2)=12 then 'IP-12'
when substring(fromnode,3,2)=41 then 'IP-41'
when FromNode%10=1 and ToNode%10=2 then 'SBU'
when FromNode%10=1 and ToNode%10=4 then 'SBL'
when FromNode%10=1 and ToNode%10=6 then 'SBT'
when FromNode%10=1 and ToNode%10=8 then 'SBR'
end BOND
from emme) emme2
ORDER BY IP

Output in SQL analyzer like this.

IP-1 IP-9 IP-12 IP-41 SBU SBL SBT SBR
1353 NULL NULL NULL NULL NULL NULL NULL
NULL 47 NULL NULL NULL NULL NULL NULL
NULL NULL 243 NULL NULL NULL NULL NULL
NULL NULL NULL 1586 NULL NULL NULL NULL
NULL NULL NULL NULL 330 NULL NULL NULL
NULL NULL NULL NULL NULL 1711 NULL NULL
NULL NULL NULL NULL NULL NULL 1980 NULL
NULL NULL NULL NULL NULL NULL NULL 1310
…….
And so on…….

I want to display result by the query like this

        SBU SBL SBT SBR
IP-1 330 1711 1980 1310
IP-9 331 1710 1981 1311
IP-12 332 1712 1982 1312
IP-41 334 1713 1983 1313
…..
and so on……

what query (changes in above query) will be use

if IP-1 then display SBU,SBL,SBT,SBR volume
if IP-9 then display SBU,SBL,SBT,SBR volume
if IP-12 then display SBU,SBL,SBT,SBR volume
if IP-41 then display SBU,SBL,SBT,SBR volume
in front of IP-1 row..

or there is alternate procedure to display above result ?

Please help

Mateen
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Returning Dodgy Result In Distress Visual Studio 2005 4 January 12th, 2007 01:19 AM
Show result from query akibaMaila VB.NET 2002/2003 Basics 2 January 18th, 2005 12:43 PM
Unexpected result from the query tsimsha Classic ASP Databases 1 August 23rd, 2004 03:50 AM
check the result of sql query Abhinav_jain_mca ADO.NET 2 August 11th, 2004 11:58 AM
Archiving query result Ned SQL Server 2000 5 October 8th, 2003 03:34 PM



All times are GMT -4. The time now is 05:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.