 |
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
|
|
|

July 7th, 2008, 02:24 AM
|
Authorized User
|
|
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 7th, 2008, 07:38 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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
================================================== =========
|

July 7th, 2008, 08:30 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 7th, 2008, 09:01 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
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
================================================== =========
|

July 7th, 2008, 09:08 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 7th, 2008, 02:07 PM
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
He is using ORACLE, since he is also using the DECODE function.
See his other post.
|

July 7th, 2008, 02:11 PM
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
|
|
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.
|
|
 |