尝试使用 mysql 获取第一个字母大写的单词

发布于 2024-11-25 11:32:00 字数 983 浏览 1 评论 0原文

我已经

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

这样做了以获得访问次数 通过使用下面的查询,

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

它给出这样的结果

                Status          Visits
                accepted         2
                refused          4

我可以得到这样的结果

                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)

我正在使用 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

安人多梦 2024-12-02 11:32:00

你可以使用 SUBSTRING上部

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

u can use SUBSTRING and UPPER

select CONCAT(UPPER(SUBSTRING(visit_Status, 1, 1)), 
      LOWER(SUBSTRING(visit_Status FROM 2))) as Status ......
烦人精 2024-12-02 11:32:00

这将做你想做的事:

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

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
獨角戲 2024-12-02 11:32:00
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
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文