| Author | Topic | 
                            
                                    | bobross80Starting Member
 
 
                                        11 Posts | 
                                            
                                            |  Posted - 2010-01-07 : 23:55:16 
 |  
                                            | I'm trying to write a query that will produce:January 2010January 2009January 2008January 2007February 2010February 2009February 2008February 2007March 2010March 2009March 2008March 2007April 2010April 2009April 2008April 2007 ...nThis is what I have so far:SELECT MonthName(Month([Program Attendance].Date)) AS TableMonth, Year([Program Attendance].Date) AS TableYearFROM [Program Attendance]GROUP BY MonthName(Month([Program Attendance].Date)), Year([Program Attendance].Date)ORDER BY Year([Program Attendance].Date) DESC, MonthName(Month([Program Attendance].Date));Its grouping by month and year, and ordering by year and month, but orders by month alphabetically. When I remove the monthname() from the order by clause and just use month(), I get an error. |  | 
       
                            
                       
                          
                            
                                    | webfredMaster Smack Fu Yak Hacker
 
 
                                    8781 Posts | 
                                        
                                          |  Posted - 2010-01-08 : 01:22:19 
 |  
                                          | What is the error message? No, you're never too old to Yak'n'Roll if you're too young to die.
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2010-01-08 : 02:38:26 
 |  
                                          | SELECT MonthName(Month([Program Attendance].Date)) AS TableMonth, Year([Program Attendance].Date) AS TableYearFROM [Program Attendance]GROUP BY MonthName(Month([Program Attendance].Date)), Year([Program Attendance].Date),Month([Program Attendance].Date)ORDER BY Year([Program Attendance].Date) DESC, Month([Program Attendance].Date);MadhivananFailing to plan is Planning to fail |  
                                          |  |  | 
                            
                       
                          
                            
                                    | webfredMaster Smack Fu Yak Hacker
 
 
                                    8781 Posts | 
                                        
                                          |  Posted - 2010-01-08 : 02:59:27 
 |  
                                          | As OP stated this was what he has tried, hence we should no the error message... No, you're never too old to Yak'n'Roll if you're too young to die.
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2010-01-08 : 03:49:40 
 |  
                                          | quote:Note that I included an extra expression in the GROUP BY ClauseMadhivananFailing to plan is Planning to failOriginally posted by webfred
 As OP stated this was what he has tried, hence we should no the error message...
 No, you're never too old to Yak'n'Roll if you're too young to die.
 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | webfredMaster Smack Fu Yak Hacker
 
 
                                    8781 Posts | 
                                        
                                          |  Posted - 2010-01-08 : 03:59:47 
 |  
                                          | Aha!I was blind. I think it is my age  quote:SELECT MonthName(Month([Program Attendance].Date)) AS TableMonth, Year([Program Attendance].Date) AS TableYearFROM [Program Attendance]GROUP BY MonthName(Month([Program Attendance].Date)), Year([Program Attendance].Date),Month([Program Attendance].Date)ORDER BY Year([Program Attendance].Date) DESC, Month([Program Attendance].Date);
 
 No, you're never too old to Yak'n'Roll if you're too young to die.
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | bobross80Starting Member
 
 
                                    11 Posts | 
                                        
                                          |  Posted - 2010-01-08 : 17:14:32 
 |  
                                          | This is the output. So close! However, January 2007 should be grouped with January 2010 on the top...Any ideas?January	 2010February 2009March    2008January	 2007April	 2007May	 2007 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | webfredMaster Smack Fu Yak Hacker
 
 
                                    8781 Posts | 
                                        
                                          |  Posted - 2010-01-08 : 18:11:44 
 |  
                                          | Then change the order by and it will work. No, you're never too old to Yak'n'Roll if you're too young to die.
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | bobross80Starting Member
 
 
                                    11 Posts | 
                                        
                                          |  Posted - 2010-01-09 : 13:35:52 
 |  
                                          | Thank you! Thank you! Thank you! |  
                                          |  |  | 
                            
                            
                                |  |