有没有办法在不使用Initcap函数的情况下转换Oracle SQl中的第一个字母大写?
我遇到的问题是,我必须使用SQL子句中的DISTINCT关键字,并且Initcap函数不起作用。
Heres是我的SQL示例:
select distinct p.nr, initcap(p.firstname), initcap(p.lastname), ill.describtion
from patient p left join illness ill
on p.id = ill.id
where p.deleted = 0
order by p.lastname, p.firstname;
我收到此错误消息:ORA-01791:不是SELECTed表达式
答案 0 :(得分:4)
尝试这样的事情:
<div class="modal-body" login-user >
<form class="custom-form" name="loginForm" ng-submit="loginSubmit()" novalidate>
<label class="museo_sans500" for="email">Nome utente o indirizzo email</label>
<input type="text" class="form-control museo_sans300" id="userName" placeholder="Nome utente o indirizzo email" ng-init="userName='<?php echo "Yesss" ?>'" name="UserName" minlength="5" ng-model="userName" required="required">
<div class="form-group">
<label class="museo_sans500" for="password">Password</label>
<input type="password" class="form-control museo_sans300" id="password" placeholder="Password" name="password" minlength="5" ng-model="password" required="required">
</div>
<div class="form-group">
<label class="museo_sans700"><a href="javascript:void(0)" ng-click="forgotPasswordShow()">Hai dimenticato la password?</a></label>
<label class="museo_sans700" style="margin-left: 30px;"><input type="checkbox" ng-model="rememberMe" name="remember-me"> Ricordami</label>
</div>
<button type="submit" class="btn play-now museo_sans500 m-t-20px login-btn" ng-disabled="loginForm.$invalid">ENTRA</button>
<div class="or museo_sans500">oppure</div>
</form>
</div>
答案 1 :(得分:4)
SELECT DISTINCT
时,您无法选择ORDER BY
列。请改为使用列别名,如:
select distinct p.nr, initcap(p.firstname) fname, initcap(p.lastname) lname, ill.describtion
from patient p left join illness ill
on p.id = ill.id
where p.deleted = 0
order by lname, fname
答案 2 :(得分:1)
这样做会,但我认为您需要发布您的查询,因为可能有更好的解决方案
select upper(substr(<column>,1,1)) || substr(<column>,2,9999) from dual
答案 3 :(得分:1)
要将“字符串”更改为“字符串”,可以使用以下命令:
从对偶中选择regexp_replace('string','[[a-z]',upper(substr('string',1,1)),1,1,'i');
这假定第一个字母是您要转换的字母。如果您输入的文本以数字开头,例如“ 2个字符串”,则不会将其更改为“ 2个字符串”。
答案 4 :(得分:0)
您也可以使用列号而不是名称或别名:
select distinct p.nr, initcap(p.firstname), initcap(p.lastname), ill.describtion
from patient p left join illness ill
on p.id = ill.id
where p.deleted = 0
order by 3, 2;