![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 This sounds like it should be super simple, but I can't think how to do it using plain SQL. I am going to display some rows, and I want to number them in the display, like using rownum, except that the number only goes up when the row has some property (I don't care if it displays or not when it doesn't go up). To explain, imagine * * * * select rownum *, the_date , to_char(dates.the_date,'DY')DAY * * * * from my_table * * * * order by the_date shows * * * * 1 * * * 1-Jan-2008 * * *TUE * * * * 2 * * * 2-Jan-2008 * * *WED * * * * 3 * * * 3-Jan-2008 * * *THU * * * * 4 * * * 4-Jan-2008 * * *FRI * * * * 5 * * * 5-Jan-2008 * * *SAT * * * * 6 * * * 6-Jan-2008 * * *SUN * * * * 7 * * * 7-Jan-2008 * * *MON * * * * 8 * * * 8-Jan-2008 * * *TUE but I don't want to count the weekend. *what I want to show would be the following instead * * * * 1 * * * 1-Jan-2008 * * *TUE * * * * 2 * * * 2-Jan-2008 * * *WED * * * * 3 * * * 3-Jan-2008 * * *THU * * * * 4 * * * 4-Jan-2008 * * *FRI * * * * * * * * 5-Jan-2008 * * *SAT * * * * * * * * 6-Jan-2008 * * *SUN * * * * 5 * * * 7-Jan-2008 * * *MON * * * * 6 * * * 8-Jan-2008 * * *TUE Looks simple, but how to do this in plain SQL? * Feedback welcome, thanks. Malcolm |
#12
| |||
| |||
|
|
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 This sounds like it should be super simple, but I can't think how to do it using plain SQL. I am going to display some rows, and I want to number them in the display, like using rownum, except that the number only goes up when the row has some property (I don't care if it displays or not when it doesn't go up). To explain, imagine * * * * select rownum *, the_date , to_char(dates.the_date,'DY')DAY * * * * from my_table * * * * order by the_date shows * * * * 1 * * * 1-Jan-2008 * * *TUE * * * * 2 * * * 2-Jan-2008 * * *WED * * * * 3 * * * 3-Jan-2008 * * *THU * * * * 4 * * * 4-Jan-2008 * * *FRI * * * * 5 * * * 5-Jan-2008 * * *SAT * * * * 6 * * * 6-Jan-2008 * * *SUN * * * * 7 * * * 7-Jan-2008 * * *MON * * * * 8 * * * 8-Jan-2008 * * *TUE but I don't want to count the weekend. *what I want to show would be the following instead * * * * 1 * * * 1-Jan-2008 * * *TUE * * * * 2 * * * 2-Jan-2008 * * *WED * * * * 3 * * * 3-Jan-2008 * * *THU * * * * 4 * * * 4-Jan-2008 * * *FRI * * * * * * * * 5-Jan-2008 * * *SAT * * * * * * * * 6-Jan-2008 * * *SUN * * * * 5 * * * 7-Jan-2008 * * *MON * * * * 6 * * * 8-Jan-2008 * * *TUE Looks simple, but how to do this in plain SQL? * Feedback welcome, thanks. Malcolm |
#13
| |||
| |||
|
|
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 This sounds like it should be super simple, but I can't think how to do it using plain SQL. I am going to display some rows, and I want to number them in the display, like using rownum, except that the number only goes up when the row has some property (I don't care if it displays or not when it doesn't go up). To explain, imagine * * * * select rownum *, the_date , to_char(dates.the_date,'DY')DAY * * * * from my_table * * * * order by the_date shows * * * * 1 * * * 1-Jan-2008 * * *TUE * * * * 2 * * * 2-Jan-2008 * * *WED * * * * 3 * * * 3-Jan-2008 * * *THU * * * * 4 * * * 4-Jan-2008 * * *FRI * * * * 5 * * * 5-Jan-2008 * * *SAT * * * * 6 * * * 6-Jan-2008 * * *SUN * * * * 7 * * * 7-Jan-2008 * * *MON * * * * 8 * * * 8-Jan-2008 * * *TUE but I don't want to count the weekend. *what I want to show would be the following instead * * * * 1 * * * 1-Jan-2008 * * *TUE * * * * 2 * * * 2-Jan-2008 * * *WED * * * * 3 * * * 3-Jan-2008 * * *THU * * * * 4 * * * 4-Jan-2008 * * *FRI * * * * * * * * 5-Jan-2008 * * *SAT * * * * * * * * 6-Jan-2008 * * *SUN * * * * 5 * * * 7-Jan-2008 * * *MON * * * * 6 * * * 8-Jan-2008 * * *TUE Looks simple, but how to do this in plain SQL? * Feedback welcome, thanks. Malcolm |
#14
| |||
| |||
|
#15
| |||
| |||
|
#16
| |||
| |||
|
#17
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |