#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    2

    Mysql-Query-sorting


    Hello I have this query;
    PHP Code:
    SELECT m.Monthcount(r.refdate) as 'all referrals'
                                            
    FROM (
                                            
    SELECT 'June' AS
                                            
    MONTH
                                            UNION SELECT 
    'July' AS
                                            
    MONTH
                                            UNION SELECT 
    'August' AS
                                            
    MONTH
                                            UNION SELECT 
    'September' AS
                                            
    MONTH
                                            UNION SELECT 
    'October' AS
                                            
    MONTH
                                            UNION SELECT 
    'November' AS
                                            
    MONTH
                                            UNION SELECT 
    'December' AS
                                            
    MONTH
                                            UNION SELECT 
    'January' AS
                                            
    MONTH
                                            UNION SELECT 
    'February' AS
                                            
    MONTH
                                            UNION SELECT 
    'March' AS
                                            
    MONTH
                                            UNION SELECT 
    'April' AS
                                            
    MONTH
                                            UNION SELECT 
    'May' AS
                                            
    MONTH
                                            
    ) AS 
                                            LEFT OUTER JOIN referrals r ON m
    .month monthname(r.refdate) and year(refdatebetween '2011' and '2012'
                                            
    group by m.month 
    can someone teach me how can I output without sorting this alphabetically. I want to out put as June - May. I is always return April-September alphabetically??
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,743
    Rep Power
    9397
    Include a number and sort by the number. Like
    Code:
    SELECT 'June AS MONTH, 1 AS whatever
    By the way, the column names only matter in the first SELECT. So you can remove them from the stuff after June to save some space.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    2
    HI! that works! thank you so much!!=) and thank for the side comment it saves me space!!!

IMN logo majestic logo threadwatch logo seochat tools logo