-
please, help me
[SIZE="5"]i have emp table it contains
empno,ename,sal,sal level
i need
sal by thouthands = * SAL LEVEL
if sal = 1000 than sal level =*
if sal = 2000 than sal level =**
if sal = 3400 than sal level =***
if sal = 15000 than sal level =***************
i donot want it static :confused:
Thanks
[/SIZE]
-
Re: please, help me
Try this
sql> set serveroutput on;
declare
cursor c1 is select empno,sal,trunc(sal/1000,0) lvl from emp;
c1r c1%rowtype;
x varchar2(255);
begin
open c1;
loop
fetch c1 into c1r ;
exit when c1%notfound;
x:=null;
if c1r.lvl >=1 then
for i in 1..c1r.lvl
loop
x:=x||'*';
end loop;
dbms_output.put_line(c1r.empno||' '||c1r.sal||' '||x);
else
dbms_output.put_line(c1r.empno||' '||c1r.sal||' '||'less than 1000');
end if;
end loop;
close c1;
end;
-
Re: please, help me
[B]thank you very much
i am Beginner in sql
and i need a simpel answer[/B]
-
Re: please, help me
Hi,
Try below query
select sal=
case
when sal> 1000 and sal <2000 then '*'
when sal> 2000 and sal <3000 then '**'
end from emp
-
Re: please, help me
Try to use the following.
It is a simple answer for EMP table.
[code]
select decode(round(sal/1000),1,'*',2,'**',3,'***',4,'****',5,'*****',6,'******',7,'*******',8,'********',9,'*********',10,'**********') from emp
[/code]
-
Re: please, help me
little change to above post
select decode(TRUNC(sal/1000),1,'*',2,'**',3,'***',4,'****',5,'*****',6,'******',7,'*******',8,'********',9,'*********',10,'**********') from SCOTT.emp
use trunc in place of round because 1600 is rounded to 2000
-
Re: please, help me
Hi you can try this select empno,ename,sal,replicate('*',round(sal,-3)/1000) ---this replicate command is for sal level:)
-
Re: please, help me
[QUOTE=Prabhakaran_220162;25678]
Hi you can try this SIMPLE TRANSACT SQL COMMAND
Select empno,ename,sal,replicate('*',round(sal,-3)/1000)
---the above replicate command is for sal level:)
[/QUOTE]
try the above Transact SQl command and let me know how it works
-
Re: please, help me
My friend this works better for you in oracle
select lpad('*',trunc(sal/1000),'*') from emp
-
Re: please, help me
[QUOTE=expertsharingdotcom;25751]My friend this works better for you in oracle
select lpad('*',trunc(sal/1000),'*') from emp[/QUOTE]
[SIZE="5"][COLOR="Magenta"]thank you for all
i try this answer and i found it is the best way i need
thanks expertsharingdotcom :)
[/COLOR][/SIZE]