Using syntax for the 'If' statement in the query?
Hi, I work at the end before the PS 9.2 via the request handler and need help
What I want to do, it's a field of expression to create
another field of expression that I can use to group on. Maybe the query like
expressions based on expressions...? Maybe because I'm on an Oracle database, I need to use Decode? If so, how can I use decode?
Details:
The field I created Gets the length of the employee in
service and it works very well
MONTHS_BETWEEN (SYSDATE, A.SERVICE_DT) / 12
It works as a character or a numeric field.
This is the problem... The next field, I would like that the query is one that goes like this...
IF ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12))
< = 4.99, "minus 5"
ELSE IF ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) > = 5 AND
((MONTHS_BETWEEN(SYSYDATE,A.SERVICE_DT)/12)) < = 9.99, "5 to 9".
ELSE IF ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) > = 10 AND
((MONTHS_BETWEEN(SYSYDATE,A.SERVICE_DT)/12)) < = 14.99, '10 to 14', "15 and"
More»
I get an error message that "a SQL error has occurred. For more details, please see your system log. Error in running because the SQL query is 972. Message = ORA-00972 identifier is too long (50 380)
Can you tell me what expression should I use? And please keep in mind that I do not have access to the SQL Developer, so I have to use the query. Thank you!... Mary
I would recommend using BOX WHEN if you're on an Oracle database. Something like:
CASE WHEN ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) <=4.99 then="" 'less="" than="" 5'="" when="" ((months_between(sysdate,a.service_dt)/12))="">= 5 AND
((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12)) <=9.99 then="" '5="" to="" 9'="" when="" ((months_between(sysdate,a.service_dt)/12))="">= 10 AND ((MONTHS_BETWEEN(SYSDATE,A.SERVICE_DT)/12))<=14.99 then="" '10="" to="" 14'="" else="" '15="" and="" over'="">=14.99>
You can find more on the syntax of the CASE on the Oracle's Web site:
http://docs.Oracle.com/CD/B19306_01/AppDev.102/b14261/case_statement.htm
=9.99>=4.99>
Tags: Oracle Applications
Similar Questions
-
Not finding the correct syntax for the select statement
Hello
The following statement works very well and gives the expected results:
As an academic exercise, I wanted to rewrite the above statement without using the WITH clause, I tried this (amongst dozens of other tests - I hit a mental block and cannot understand):prompt prompt Using WITH t prompt with t as ( select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) select proj_id, proj_start, proj_end, flag, -- -- the following select statement is what I am having a hard time -- "duplicating" without using the WITH clause -- ( select sum(t2.flag) from t t2 where t2.proj_end <= t.proj_end ) s from t;
Thanks for the help, much appreciated.prompt prompt without with prompt select c.proj_id, c.proj_start, c.proj_end, c.flag, -- -- This is what I've tried as the equivalent statement but, it is -- syntactically incorrect. What's the correct syntax for what this -- statement is intended ? -- ( select sum(t2.flag) from c t2 where t2.proj_end <= c.proj_end ) as proj_grp from ( select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) c;
John.
PS: The DDL for table v used by the above statements is:
drop table v; create table v ( proj_id number, proj_start date, proj_end date ); insert into v values ( 1, to_date('01-JAN-2005', 'dd-mon-yyyy'), to_date('02-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 2, to_date('02-JAN-2005', 'dd-mon-yyyy'), to_date('03-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 3, to_date('03-JAN-2005', 'dd-mon-yyyy'), to_date('04-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 4, to_date('04-JAN-2005', 'dd-mon-yyyy'), to_date('05-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 5, to_date('06-JAN-2005', 'dd-mon-yyyy'), to_date('07-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 6, to_date('16-JAN-2005', 'dd-mon-yyyy'), to_date('17-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 7, to_date('17-JAN-2005', 'dd-mon-yyyy'), to_date('18-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 8, to_date('18-JAN-2005', 'dd-mon-yyyy'), to_date('19-JAN-2005', 'dd-mon-yyyy')); insert into v values ( 9, to_date('19-JAN-2005', 'dd-mon-yyyy'), to_date('20-JAN-2005', 'dd-mon-yyyy')); insert into v values (10, to_date('21-JAN-2005', 'dd-mon-yyyy'), to_date('22-JAN-2005', 'dd-mon-yyyy')); insert into v values (11, to_date('26-JAN-2005', 'dd-mon-yyyy'), to_date('27-JAN-2005', 'dd-mon-yyyy')); insert into v values (12, to_date('27-JAN-2005', 'dd-mon-yyyy'), to_date('28-JAN-2005', 'dd-mon-yyyy')); insert into v values (13, to_date('28-JAN-2005', 'dd-mon-yyyy'), to_date('29-JAN-2005', 'dd-mon-yyyy')); insert into v values (14, to_date('29-JAN-2005', 'dd-mon-yyyy'), to_date('30-JAN-2005', 'dd-mon-yyyy'));
select c.proj_id, c.proj_start, c.proj_end, c.flag, -- -- This is what I've tried as the equivalent statement but, it is -- syntactically incorrect. What's the correct syntax for what this -- statement is intended ? -- ( select sum(t2.flag) from (select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) t2 where t2.proj_end <= c.proj_end ) as proj_grp from ( select a.proj_id, a.proj_start, a.proj_end, case when ( select min(a.proj_start) from v b where (a.proj_start = b.proj_end) and (a.proj_id != b.proj_id) ) is not null then 0 else 1 end as flag from v a order by a.proj_start ) c;
-
Why I always get direction is not available when you use maps for the iPhone 6 more?
Currently I live in the Qatar.
Hi Alison, Sameh
The reason why you see directions is not available, it's that for cards of Apple, turn-by-turn directions is not a feature that is available in the Qatar. You can search for places and satellite imagery
Take a look at the link below for more details on what features are available in the Qatar.iOS 9 feature availability
http://www.Apple.com/iOS/feature-availability/Nice day
-
Well not much description required in this case. I was using firefox for the first time on a mac and so was trying new things with this version of firefox. Just got stuck with these separators xtra... Can't find a way to get them off of my bookmarks toolbar...
You can open the Bookmark Manager (Bookmarks > show all bookmarks) and go to the Favorites bar folder in the left pane.
You can then remove the separators in the right pane. -
Can I use java for the development of the playbook?
Hi I'm new in blackberry development. I've owned playbook and that you want to develop playbook apps, but I can only develop in java. Please, someone tell me what I can use java for the development of the Tablet?
Bilal
# You can convert by android android applications, run-time.
Explore these links
-
I installed driver ux 16 in my widows 7 and connected to my pc but nothing displays, no .so tracks what is wrong with it please suggest.or how can I do this by using midi for the first time.
In the subject line, type a brief description of your problem or your question. A subject line that says only "Hi alll" not will receive the attention of someone who can be familiar with your particular situation.
Contact the support of Yamaha.
-
syntax for the compilation of the pll in oracle11i on windows files
Hello
What is the syntax for the compilation of files of pll in oracle11i?
When executing pll, I got the below error
E:\oracle\testappl\au\11.5.0\resource > f60gen module = CUSTOM.pll userid = apps/app0305apps output_file = CUSTOM.plx
module_type = library package = no compile_all = special
'f60gen' is not recognized as an internal or external command
operable program or batch file.
Thank you
Regarding
UmairUmair,
I changed the fichier_de_sortie so I ran which command that was successful.
It should work, but you must replace the original file, so enforcement is necessary.
Means I have to stop application services (forms + Apache).
Correct (mainly the forms).
Kind regards
Hussein -
Using NVL in the query in the query resulting in error
I always use CF8 and Oracle 11 G back.
When I use NVL in the query in the query, I got error... I can't use NVL to check the value null? Help, please
Here are my codes:
< name cfquery = "GetC2" datasource = "#Trim (application." OracDSN) #">" SELECT CamID2, rel2_2, p_ln2, p_fn2, ins, l_year
OF prt_temp
WHERE Ins = 'CC '.
AND l_year = '1481'
AND NVL (Child_LN2,' ') <>' ' AND NVL (Child_FN2,' ') <>' ' < / cfquery >
< cfif GetC2.Recordcount NEQ 0 > < cfquery name = "CheckRel2C2", dbtype = "QUERY" > SELECT CamID2, rel2_2 OF GetC2 WHERE NVL (Rel2_2,' ') <>' ' AND NVL (p_ln2,' ') = ' ' AND NVL (p_fn2,' ') = ' ' AND Ins = 'CC '. AND l_year = '1481' < / cfquery > < / cfif > The error:
Run database query error.
Query of queries syntax error.
Met «NVL (Rel2_2.» Incorrect conditional expression, waiting for an a [as | null | between | in | comparison] condition,.
NVL is an Oracle function and it is not available in ColdFusion query of query. If you try to check the values null, use IS NULL or IS NOT NULL. Then
WHERE NVL (Rel2_2,' ') <> ' '
AND NVL (p_ln2,' ') = ' '
AND NVL (p_fn2,' ') = ' '
becomes
WHERE Rel2_2 IS NOT NULL
AND p_ln2 IS NULL
AND p_fn2 IS NULL
-Carl V.
-
What is the correct syntax for the use of a variable in an ad-hoc query?
Hi all
I'm a casual user of the DB and right now need to update the records about 1000 + so that a certain column gets a unique value.
So I thought I'd use a variable for this.
Then, I built this type of SQL statement for only a small subset of records:
----------
variable number recNumber;
exec: recNumber: = 1;
UPDATE TABLE_TO_BE_UPD
SET COL_TO_BE_UPD = COL_TO_BE_UPD + recNumber
WHERE COL_TO_BE_UPD IN ('VAL_A', 'VAL_B');
----------
I get invalid SQL statement error when you try to run above (except for the guest who asks for a value I want to omit).
In any case, I also tried this one:
----------
CREATE SEQUENCE seqCounter;
UPDATE TABLE_TO_BE_UPD
SET COL_TO_BE_UPD = COL_TO_BE_UPD + seqCounter.NEXTVAL
WHERE COL_TO_BE_UPD IN ('VAL_A', 'VAL_B');
----------
Of it, I got the error ORA-01722: invalid number... I guess it's because seqCounter is of type number and the COL_TO_BE_UPD is of type character... (?)
Then I want to ask is what is the correct way to define and use a counter variable type to add a number at the end of a string?
Also another question I would ask is that are variables that are used in queries ad hoc, also called "bind variables"?
Thank you muchlyIf you want to add a unique number to a column, then it would be:
UPDATE TABLE_TO_BE_UPD SET COL_TO_BE_UPD = COL_TO_BE_UPD ||to_char(rownum) WHERE COL_TO_BE_UPD IN ('VAL_A','VAL_B');
-
How the group using SQL for the desired output.
Hi all
I am currently using oracle 10.2.0.4.0
Create a table script:
INSERT statement:CREATE TABLE FORTEST ( gpno VARCHAR2(10 BYTE), classnumber VARCHAR2(10 byte), age_min NUMBER, age_max NUMBER, amount NUMBER)
power required:insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 01,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 01,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 01,36,40,3) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 02,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 02,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 02,36,40,5) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 03,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 03,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G123' , 03,36,40,3) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G124' , 01,0,29,1) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G124' , 01,30,35,2) insert into fortest (GPNO,classnumber,age_min,age_max,amount) values ('G124' , 01,36,40,3)
as for gpno g123, classnumber 1 and 3, the rates are the same in all the age_min and age_max they need to be grouped.gpno classnumber age_min age_max amount G123 1,3 0 29 1 G123 1,3 30 35 2 G123 1,3 36 40 3 G123 2 0 29 1 G123 2 30 35 2 G123 2 36 40 5 G124 1 0 29 1 G124 1 30 35 2 G124 1 36 40 3
even if gpno 123 classnumber 2 has the same rates as the classesnumber 1 and 3 for the age groups 0 to 29 and 30 to 35,
rates are different for ages 36 to 40. so it should not be placed together. How can I do this in SQL
any help is appreciated.
Thanks in advance.Hello
Thorny problem!
Unfortunately, LISTAGG was created to the Oracle 11.2. About half of the complexity here is the aggregation of chain, i.e. forming the list of the classnumbers, as '1.3', using only functions available in Oracle 10.2.
Here's a solution:
WITH got_gpno_classnumber_cnt AS ( SELECT gpno, classnumber, age_min, age_max, amount , COUNT (*) OVER ( PARTITION BY gpno , classnumber ) AS gpno_classnumber_cnt FROM fortest -- WHERE ... -- If you need any filtering, this is where it goes ) , pairs AS ( SELECT a.gpno , a.classnumber , MIN (b.classnumber) OVER ( PARTITION BY a.gpno , a.classnumber ) AS super_classnumber FROM got_gpno_classnumber_cnt a JOIN got_gpno_classnumber_cnt b ON a.gpno = b.gpno AND a.age_min = b.age_min AND a.age_max = b.age_max AND a.amount = b.amount AND a.gpno_classnumber_cnt = b.gpno_classnumber_cnt GROUP BY a.gpno , a.classnumber , b.classnumber HAVING COUNT (*) = MIN (a.gpno_classnumber_cnt) ) , got_rnk AS ( SELECT DISTINCT gpno, classnumber, super_classnumber , DENSE_RANK () OVER ( PARTITION BY gpno , super_classnumber ORDER BY classnumber ) AS rnk FROM pairs ) , got_classnumbers AS ( SELECT gpno, classnumber, super_classnumber , SUBSTR ( SYS_CONNECT_BY_PATH (classnumber, ',') , 2 ) AS classnumbers FROM got_rnk WHERE CONNECT_BY_ISLEAF = 1 START WITH rnk = 1 CONNECT BY rnk = PRIOR rnk + 1 AND gpno = PRIOR gpno AND super_classnumber = PRIOR super_classnumber ) SELECT DISTINCT g.gpno , c.classnumbers , g.age_min , g.age_max , g.amount FROM got_gpno_classnumber_cnt g JOIN got_classnumbers c ON c.gpno = g.gpno AND c.classnumber = g.classnumber ORDER BY g.gpno , c.classnumbers ;
Out (just as you requested):
GPNO CLASSNUMBERS AGE_MIN AGE_MAX AMOUNT ---------- --------------- ---------- ---------- ---------- G123 1,3 0 29 1 G123 1,3 30 35 2 G123 1,3 36 40 3 G123 2 0 29 1 G123 2 30 35 2 G123 2 36 40 5 G124 1 0 29 1 G124 1 30 35 2 G124 1 36 40 3
-
None of the explanations in support of Mozilla are useful. I went to tools and looked for the saved passwords and was not listed. I tried the password associated with my Verizon account, but the message keeps appearing. Recently I change my password for Verizon. I tried the old and the new. I always get the message box. Why? How can I get rid of him? It affects my outgoing emails?
davislawn, were you able to solve your problem?
-
Using aliases for the indicators, controls, procedures and calculated channels
Hello
I noticed that aliases do not appear in the workspace for the controls and indicators and procedures system Explorer and see calculated. Is there a way for them to appear? I need to use aliases because I like my definition of the system to control several test systems (which have different CAN report names). Otherwise my system definition would break every time I go to another CAN the database. I thought that the inability to address limited to the configurable alias controls add on, but it seems that VeriStand natively cannot address the areas I would like to also well done right click. Any recommendations would be welcome.
Thank you.
You are right that you cannot use alias in a file system definition for mapping purposes. It is an area that we hope to improve in the future. The initial design of alias was to serve as a public interface for the workspace, profiles of stimulus and so on. However, it is certainly a use case valid to be used as an interface in a system definition.
A possible solution would be to create a set of user channels that play the public role of your interface in your system definition. Always use your user channels in all procedures, calculated channels and so on. Map your CAN channels on these channels to the user. Whenever you update YOUR database, you must remap the new CAN channels to the appropriate user channel. You can also automate this activity by importing a file delimited by tabs on the mappings page. The one drawback here is that your target will take a little more time to deal with these mappings.
-
has no success of body to toggel Port0 and Port1 aboard MCB2300 using LV for the ARMS?
I'm trying to toggel the GPIO (Port0, Port1) on the evaluation package of MCB2300 with LPC2378 uController aboard by using LV8.6. These two ports seems to have no programmable features with the help of 2 Ports NV., 3 and Port4 work well. If any body got these two ports in the work, so it will be great if you could post a functional LV or C code here in the forum.
I will be grateful for any suggestions or advice.
Greetings
Hello AMD.
I posted the solution to this elsewhere (although I admit that it is not easy to find).
Here you go: http://forums.ni.com/ni/board/message?board.id=420&message.id=1185#M1185
In this post, I am referring to the evolution of the model for the generic lpc2378 target project. If you use the target of MCB2300 (as it seems you are), you need to open the project to C:\Program NIUninstaller Instruments\LabVIEW 8.6\Targets\Keil\Embedded\RealView\MCB2300\Template\Project\LabVIEW.uv2
The side effect of this change is that the LCD on the MCB2300 no longer works (as it activates / deactivates the GPIO slow/legacy records). So you can either return the above changes or modifies registry addresses in the LCD display driver to point to the fast GPIO registers.
This problem should be solved in the next version of LabVIEW for ARM.
Good luck
-
CPU use 100% for the NT kernel & system
On the Task Manager CPU usage is 100% for the NT kernel & system so my PC is going very slowly
AMD Athlon X 2 7750 2.7 Ghz
2 Ghz of RAMHello
See following message if you suspect malware has a role to play.
CTRL SHIFT ESC or right click on taskbar - task manager.
Manager of task - performance tab - resource monitor - any info on what might be executed on the
CPU box (click on the small neighborhood down right).What happens in Mode without fail - repeatedly, press F8 as you boot?
How to troubleshoot a problem by performing a clean boot in Windows Vista
http://support.Microsoft.com/kb/929135
How to troubleshoot performance issues in Windows Vista
http://support.Microsoft.com/kb/950685Optimize the performance of Microsoft Windows Vista
http://support.Microsoft.com/kb/959062
To see everything that is in charge of startup - wait a few minutes without doing anything - then right click on the task - bar
The task manager - take a look at stored by - Services - process - it is a quick reference (if you have
a small box in the lower-left - show for all users can check only).How to check and change Vista startup programs
http://www.Vistax64.com/tutorials/79612-startup-programs-enable-disable.htmlA quick check to see that load method 2 is - using MSCONFIG and then display a list of the people here.
--------------------------------------------------------------------Tools that should help you:
Process Explorer - free - find out what are the files, registry keys and other objects processes have opened, the dll
they loaded and much more. This exceptionally effective utility will show you even owned by each process.
http://TechNet.Microsoft.com/en-us/Sysinternals/bb896653.aspxAutoruns - free - see what programs are configured to startup automatically when your system boots and you
opening of session. Autoruns also shows you the full list of registry and file locations where applications can configure auto-
start the settings.
http://TechNet.Microsoft.com/en-us/sysinternals/bb963902.aspx
Process Monitor - Free - monitor the system files, registry, process, thread and DLL real-time activity.
http://TechNet.Microsoft.com/en-us/Sysinternals/bb896645.aspxThere are many excellent free tools from Sysinternals
http://TechNet.Microsoft.com/en-us/Sysinternals/default.aspxWhatsInStartUP - free - this utility displays the list of all applications that are loaded automatically when Windows
starts. For each request, the following information is displayed: Startup Type (registry/Startup folder).
The command - line String, product name, file Version, company name, location in the registry or the file system,
and much more. It allows you to easily disable or remove unwanted programs that runs in your Windows startup.
http://www.NirSoft.NET/utils/what_run_in_startup.htmlThere are many excellent free tools to NirSoft
http://www.NirSoft.NET/utils/index.htmlWindow Watcher - free - do you know what is running on your computer? Maybe not. The window Watcher says it all, reporting of any window created by all running programs, if the window is visible or not.
http://www.KarenWare.com/PowerTools/ptwinwatch.aspMany excellent free tools and an excellent newsletter at Karenware
http://www.KarenWare.com/Hope these helps.
Rob - bicycle - Mark Twain said it is good.
-
Using configuration for the 2nd link of lan to lan vpn
Hello
Successfully, I configured a connection of lan to lan vpn between two offices. I try to add another link to a 3rd office to my office at home, but have some difficulty. I have attached my setup and hope someone can help me solve my problem. Right now I have a working vpn to the 172.16.0.0/24 network and putting in place the link to 172.16.3.0/24 so. For the new vpn connection, I can ping the external interfaces, but can't ping anything in-house.
Thanks for your time and help,
Jason
Jason
There is a major mistake that's easy to fix. You have successfully created a second instance of the encryption card to create a VPN tunnel for the second site. But as currently configured two instances of the encryption card use the same access list:
1 ipsec-isakmp crypto map clientmap
match address 100
5 ipsec-isakmp crypto map clientmap
match address 100
But each session/tunnel VPN needs its own access list. So, I suggest that you make the following changes:
5 ipsec-isakmp crypto map clientmap
match address 101
no access list 100
access-list 100 permit ip 192.168.0.0 0.0.0.255 172.16.0.0 0.0.0.255
access-list 101 permit ip 192.168.0.0 0.0.0.255 172.16.3.0 0.0.0.255
This provides a list of separate for each session/tunnel access and should solve this problem. Try it and tell us the result.
HTH
Rick
Maybe you are looking for
-
Every time I open the document, and I add a new line and add a new time, the rest of the chart changes and goes flat. Why this keep happening?
-
Why my username is rejected in Google Personas, even if this is correct?
Successfully, I recorded in Google Personas and applied to a character of Thanksgiving a few weeks ago. I can not connect because my username is not accepted (?) I KNOW I entered the correct data because I recorded it for reference. I would like to g
-
Music library syncing my iPhone to my Mac
I recently bought a Macbook Pro (move from a Windows-based computer) and after syncing my iPhone to my Macbook, I noticed that my entire library of music on my iPhone does not sync to my Macbook. I'm not 100% sure but I think that only the music that
-
4015 creasing on the long side
I have a 4015 that puts a small crease on the long side of the paper. It's more noticeable down to 1/3 of the leaf. Recently, I replaced the fuser unit.
-
Pavilion dv2 laptop: how to drive to create an Image for Vista?
Due to d/l & updated Vista installation problems, I decided to use my HP recovery disks to restore my laptop as long as you plant. It seemed like the most logical approach to carry out several tasks, such as deleting a 2nd user & general cleaning of