Take 2 digit after comma sql [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 months ago.
Improve this question
So, i have column with data type float. i want to take 2 digit after comma
example
0.622
i want the result is
0.62
i already tried some solution from stack overflow but still the result is 0.61.
sum(CASE WHEN a.TOTALBUDGET>bo.Bobot*2 then bo.Bobot*2 else a.totalbudget end) as UW_Rank
sum(CASE WHEN a.TOTALBUDGET>bo.Bobot*2 then bo.Bobot*2 else CAST(ROUND(a.totalbudget,2,1)AS NUMERIC(18,2)) end) as UW_Rank_Test
thanks

Did you tried round function.
declare #val float = '0.622'
SELECT ROUND(#val, 2);

Related

In Sql developer ,How to remove the last 3 digit from string in all rows for one column? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 months ago.
Improve this question
Colum2
Karim_bk
Karim_bk
Karim_bk
Want result Karim
This should work
select top 10 Lastname, LEFT(Lastname, LEN(Lastname) - 3) as TrimmedVersion from tablename
Hope this will help you. In Oracle:
SELECT SUBSTR(column_name, 0, LENGTH(column_name) - 2) from table_name;
--SELECT SUBSTR('karim_bk', 0, LENGTH('karim_bk') - 2) from dual; --karim

Oracle SQL Select Only 5 Digit Row in a Column [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
SELECT *
FROM GNGRB.CLAIM
WHERE ZOCRECDT IS NOT NULL;
SLNO Column select only 5 digit row
Please use length function of oracle. For e.g:
select *
from table a
where length(a.column_name) = 5
In your case
SELECT *
FROM GNGRB.CLAIM
WHERE ZOCRECDT IS NOT NULL
and LENGTH(SLNO) = 5

SQL- The Decode Function greater than [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm trying the decode function but I can't get it work - please help.
select
naam, maandsal*2, mnr,
DECODE(maandsal * 2 > mnr, maandsal * 2),
DECODE(mnr > maandsal , mnr)
from
medewerkers;
Use case:
select naam, maandsal2, mnr,
(case when maandsal2 > mnr then maandsal*2 end),
(case when mnr > maandsal then mnr end)
from medewerkers;

case when with count [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a quick sql data as below,
Customerid,Type
1,Adult
1,Adult
2,Adult
3,Adult
4,Teenager
4,Adult
I want the query that lists those customer no.s that do not have any other Type associated with them. For eg. 1 as only Adult associated with, same with 2. But 3 and 4 have multiple Types associated with them.
I am trying to get an output as below.
Customerid,Type
1,Adult
2,Adult
3,null
How should we tackle this.
You seem to want:
select customerid
, (case when min(type) = max(type) then min(type) end) as type
from table t
group by customerid;

Select a part of a selected item in sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can I possibly select a part of a row data in MS Sql?
ex. Charmina (Female)
All I want to select is the Female not the whole Charmina (Female)
Try this
select substring('Charmina (Female)',
charindex('(','Charmina (Female)')+1,
LEN('Charmina (Female)')-charindex('(','Charmina (Female)')-1)
or
select stuff('Charmina (Female)',1,charindex('(','Charmina (Female)')-1,'')
You may Use SUBSTRING to get sub sequences of strings
SELECT SUBSTRING( your_Raw ,start , length ) AS Alias
FROM Your_Table