| Author | 
                                
                                 Topic  | 
                            
                            
                                    | 
                                         mrhardy76 
                                        Starting Member 
                                         
                                        
                                        6 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2008-07-10 : 08:43:46
                                            
  | 
                                             
                                            
                                            | How do write and execute a PL/SQL script to print running total of numbers 1 to 10? | 
                                             
                                         
                                     | 
                            
       
                            
                       
                          
                            
                                    | 
                                     jhocutt 
                                    Constraint Violating Yak Guru 
                                     
                                    
                                    385 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-10 : 08:51:18
                                          
  | 
                                         
                                        
                                          | select sum(MyNumber) MyHomeWorkAnswer from (	select 1 as MyNumber union all	select 2 as MyNumber union all	select 3 as MyNumber union all	select 4 as MyNumber union all	select 5 as MyNumber union all	select 6 as MyNumber union all	select 7 as MyNumber union all	select 8 as MyNumber union all	select 9 as MyNumber union all	select 10 as MyNumber ) MyHomeWork"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen."  --  Stephen Hawking  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     elancaster 
                                    A very urgent SQL Yakette 
                                     
                                    
                                    1208 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-10 : 09:16:17
                                          
  | 
                                         
                                        
                                          | PL SQL ....as in Oracle?Em  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     jhocutt 
                                    Constraint Violating Yak Guru 
                                     
                                    
                                    385 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-10 : 09:18:17
                                          
  | 
                                         
                                        
                                          | I must be asleep I didn't even see that."God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen."  --  Stephen Hawking  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     jimf 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    2875 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-10 : 09:19:45
                                          
  | 
                                         
                                        
                                          | This is a Microsoft Sequel Server forum, so you may want to double-check this code to see if it works in OracleJimDECLARE @homework TABLE (col1 int)INSERT INTO @homeworkselect 1 as MyNumber union allselect 2 as MyNumber union allselect 3 as MyNumber union allselect 4 as MyNumber union allselect 5 as MyNumber union allselect 6 as MyNumber union allselect 7 as MyNumber union allselect 8 as MyNumber union allselect 9 as MyNumber union allselect 10 as MyNumber SELECT a.col1,sum(b.col1) FROM @homework aINNER JOIN    @homework bON  a.col1 >= b.col1GROUP BY    a.col1  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     khtan 
                                    In (Som, Ni, Yak) 
                                     
                                    
                                    17689 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-10 : 09:22:16
                                          
  | 
                                         
                                        
                                          maybe you will get extra credit by submitting a T-SQL solution KH[spoiler]Time is always against us[/spoiler]  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     jhocutt 
                                    Constraint Violating Yak Guru 
                                     
                                    
                                    385 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-10 : 09:30:26
                                          
  | 
                                         
                                        
                                          | For Oracle try select sum(rownum) as MyHomework from tab where rownum < 11"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen."  --  Stephen Hawking  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     mrhardy76 
                                    Starting Member 
                                     
                                    
                                    6 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-10 : 12:49:29
                                          
  | 
                                         
                                        
                                          yes.  I need to use for loop as well.quote: Originally posted by elancaster PL SQL ....as in Oracle?Em
    | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     elancaster 
                                    A very urgent SQL Yakette 
                                     
                                    
                                    1208 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-11 : 03:14:57
                                          
  | 
                                         
                                        
                                          | I think you would probably be best to post your queries on an Oracle Forum. As stated, this is specifically for SQL Server problemsEm  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     SwePeso 
                                    Patron Saint of Lost Yaks 
                                     
                                    
                                    30421 Posts  | 
                                    
                                      
                                     | 
                                  
                            
                       
                          
                            
                                    | 
                                     madhivanan 
                                    Premature Yak Congratulator 
                                     
                                    
                                    22864 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-07-15 : 08:57:33
                                          
  | 
                                         
                                        
                                          quote: Originally posted by mrhardy76 yes.  I need to use for loop as well.quote: Originally posted by elancaster PL SQL ....as in Oracle?Em
  
  Why?MadhivananFailing to plan is Planning to fail  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                  
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 |