| Author |
Topic |
|
Ltran
Starting Member
4 Posts |
Posted - 2005-09-28 : 21:39:37
|
| Hi, everyone. I'm a beginner so my question might be silly.If I have a table as below:Letter No.A 1B 2C 2How to write a query without using Cursor/SP/View to return:Letter No.A 1B 2B 3C 4C 5Thanks in advance |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-09-28 : 21:44:59
|
| The requirements don't make any sense, so it must be HOMEWORK.CODO ERGO SUM |
 |
|
|
Ltran
Starting Member
4 Posts |
Posted - 2005-09-28 : 21:49:08
|
| Sorry what don't make any sense? |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-09-28 : 23:29:55
|
| The requirement to "write a query without using Cursor/SP/View to return". Why would that be a requirement for a real world application? So the only conclusion is that this is a homework problem for a class.CODO ERGO SUM |
 |
|
|
Ltran
Starting Member
4 Posts |
Posted - 2005-09-29 : 00:03:47
|
| Well, my SQL Server login account is rectricted by the DBA so that I can not create SP, View. I can only use simple Select command.Don't think that I'm s student looking for an answer to a homework. Thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-29 : 01:59:21
|
| Can you tell us the logic you want to use to get those result?MadhivananFailing to plan is Planning to fail |
 |
|
|
Ltran
Starting Member
4 Posts |
Posted - 2005-09-29 : 02:39:45
|
| Madhivanan, thanks for helping a beginner. Refer to my example, I hope I can explain it wellIf The No. Column = 1, then return as it is, i.e Letter A with No. 1If The No. Column > 1, then return the Letter with No. 1 n times until n = No., i.e Letter 'B' and 'C' with No. 2 Suppose I have another tableLetter No.A 5B 2C 3D 1My query would returnLetter No.A 1A 1A 1A 1A 1B 1B 1C 1C 1C 1D 1 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-29 : 02:48:03
|
| Post the query you usedMadhivananFailing to plan is Planning to fail |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-09-29 : 06:23:38
|
I don't think he can restrict you from using a cursor.Also, I don't think he can prevent you from creating a temporay stored procedure ( create proc #temp_procname...) and executing that.quote: Originally posted by Ltran Well, my SQL Server login account is rectricted by the DBA so that I can not create SP, View. I can only use simple Select command.Don't think that I'm s student looking for an answer to a homework. Thanks
CODO ERGO SUM |
 |
|
|
|