user682417
user682417

Reputation: 1518

trying to get the word with starting upper case on first letter using mysql

I have

              Visit table 
                 Visit_Id
                 Visit_Date values(09-09-2011)
                 Visit_status values like (accepted , refused)
                member_Id

i have done like this for getting number of visits by using below query

SELECT visit_Status as Status, COUNT('x') AS Visits
                              FROM visits
                              WHERE visit_Date BETWEEN '2011-06-20' AND '2011-07-20'
                              GROUP BY visit_Status

it was giving results like this

                Status          Visits
                accepted         2
                refused          4

can i get the results like this

                Status          Visits

                Accepted         2
                Refused          4


      with upper case letter on first letter of status i mean like this ( Accepted , Refused) instead of this one  (accepted , refused)

I am using mysql work bench

Upvotes: 4

Views: 1536

Answers (3)

Talha Ahmed Khan
Talha Ahmed Khan

Reputation: 15433

SELECT CONCAT(UPPER(SUBSTRING(Visit_status, 1, 1)), SUBSTRING(Visit_status FROM 2)) as Status, COUNT('x') AS Visits
FROM visits
WHERE visit_Date BETWEEN '2011-06-20' AND '2011-07-20'
GROUP BY visit_Status

Upvotes: 1

bruno
bruno

Reputation: 2882

This will do what you want:

SELECT CONCAT(UPPER(SUBSTRING(Visit_status, 1, 1)), LOWER(SUBSTRING(Visit_status FROM 2))) AS Status COUNT('x') AS Visits
       FROM visits
      WHERE visit_Date BETWEEN '2011-06-20' AND '2011-07-20'
      GROUP BY visit_Status

Upvotes: 2

Haim Evgi
Haim Evgi

Reputation: 125496

u can use SUBSTRING and UPPER

select CONCAT(UPPER(SUBSTRING(visit_Status, 1, 1)), 
      LOWER(SUBSTRING(visit_Status FROM 2))) as Status ......

Upvotes: 6

Related Questions