user1593511
user1593511

Reputation: 1

SQL stored procedure

My problem is I’m going to create a SQL stored procedure so that I can create a report based from the stored procedure.

Question: How will I be able to display the records in the following sequence?

ABCON                       
67890      2/1/2012                     
123        2/10/2012                    
456        3/10/2012                    
789        3/11/2012                    
DEFON                           
222        3/12/2012                    
333        3/18/2012                    
GHION                               
67890      4/1/2012                     
444        5/1/2012                     
555        5/15/2012                    
789        06/11/2012                       

Given sample table:

  Column1   Column2   Column3   ColDate  
  ABCON     67890               02/01/2012  
              123      67890    02/10/2012   
              456        123    03/10/2012   
  DEFON       222           03/12/2012  
              333        222     3/18/2012    
  GHION     67890               04/01/2012   
              444     67890     05/01/2012   
              555       444      5/15/2012   
              789       456     06/11/2012 

Upvotes: 0

Views: 175

Answers (2)

Prince Jea
Prince Jea

Reputation: 5680

This code should work.

SELECT Column1, Column2,Column2, ColDate
FROM yourTable
ORDER BY ColDate ASC

NOTE: To display the data in the report like this you need to use the GROUP function in what report are you using

 ABCON                       
    67890      2/1/2012                     
    123        2/10/2012                    
    456        3/10/2012                    
    789        3/11/2012                    
    DEFON                           
    222        3/12/2012                    
    333        3/18/2012                    
    GHION                               
    67890      4/1/2012                     
    444        5/1/2012                     
    555        5/15/2012                    
    789        06/11/2012 

Upvotes: 2

Hogan
Hogan

Reputation: 70513

SELECT Column1, Column2, ColDate
FROM sampletable
ORDER BY ColDate ASC

Upvotes: 1

Related Questions