Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2008, 02:24 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display Row No.

How can i display the row numbers of the results of the below statements:
SUM(CASE WHEN ITED_TED_CODE ='BED' THEN ITED_NET_LC_AMT ELSE 0 END)AS BED,
SUM(CASE WHEN ITED_TED_CODE ='EDU CESS' THEN ITED_NET_LC_AMT ELSE 0 END) AS EDUCESS,
SUM(CASE WHEN ITED_TED_CODE ='SHECESS' THEN ITED_NET_LC_AMT ELSE 0 END) AS SHECESS,
SUM(CASE WHEN ITED_TED_CODE ='BED CT3' THEN ITED_NET_LC_AMT ELSE 0 END) AS BEDCT3,
SUM(CASE WHEN ITED_TED_CODE ='EDU CESS CT3' THEN ITED_NET_LC_AMT ELSE 0 END) AS EDUCT3,
SUM(CASE WHEN ITED_TED_CODE ='SHECESS CT3' THEN ITED_NET_LC_AMT ELSE 0 END) AS SHECT3,*/


Yogesh
__________________
Yogesh
 
Old July 7th, 2008, 07:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

What do you want as row number?? there is no row number in a database (at least not in a modern one)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old July 7th, 2008, 08:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Gonzalo,

Your information is out of date.

Microsoft SQL Server 2005 now has a ROW_NUMBER ranking function that can be used with result sets.

Rand E. Gerald



Rand
 
Old July 7th, 2008, 09:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

wow.. sorry about that them...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old July 7th, 2008, 09:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Of course, if Yogeshyl is using some other database or an earlier version of SQL Server, my reply is meaningless.

BTW: I had to look it up in the SQL Server 2005 manual. That is a new feature that I haven't had a chance to use yet. We are in the process of converting our databases from SQL Server 2000 to SQL Server 2005.

Rand
 
Old July 7th, 2008, 02:07 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

He is using ORACLE, since he is also using the DECODE function.

See his other post.
 
Old July 7th, 2008, 02:11 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

The original question doesn't really make any sense, though, no matter how you look at it.

First of all, "the below statements" are *NOT* statements; they are simply individual fields in a *SINGLE* record.

So *IF* this was SQL Server 2005, he migh do

SELECT ROW_NUMBER, SUM(...) AS BED, SUM(...) AS EDUCESS, ...

But then he would have only *ONE* row (number 1) unless he has other things in the query that create other rows (and he does).

But in any case, *each* of those SUM( )s would *NOT* have its own row number.

So I, for one, don't understand the point of the question, at all.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Decode function to display result in same row yogeshyl SQL Language 0 July 2nd, 2008 12:40 AM
Display multiple records / row in DataGrid angshujit ASP.NET 2.0 Basics 0 January 18th, 2007 07:03 AM
Display DataGrid footer after last row only demivolt ASP.NET 1.0 and 1.1 Professional 2 August 9th, 2005 08:39 AM
how to display image and text in a same table row faisal bashir ASP.NET 1.0 and 1.1 Basics 0 August 9th, 2005 02:03 AM
Read a column and Search Row by Row in another col AyatKh Excel VBA 2 January 26th, 2005 12:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.