SQL- The Decode Function greater than [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 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;

Related

Take 2 digit after comma 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 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);

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

Hive output query for selecting particular value based on groupby clause [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 6 years ago.
Improve this question
I have a table with data like:
cust_id, acct_no, ind
123111, 1233, Y
123111, 2311, N
222111, 1112, N
222111, 2111, N
I have to get output as cust_id, 1 (a binary indicator if any of the acct under that customer is Y)
so from the above table I have to get below output.
123111 1
222111 0
A simple way to achieve this is something like:
select cust_id, max(case when ind = 'Y' then 1 else 0 end) as flag from customers group by cust_id;

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