How to get 3 months based on sysdate in command prompt
HelloI use fiscal months in the guests and the data in the column looks at below
201201
201202
201203
201204
The user will select the guests between months, as below
Between 201201 and 201204.
My requirement is I need this month value of exercise in the last 3 months, by default since we are in February, it should look like this.
Between 201211 and 201301 (3 months)
Rgds,
My
between to_char(add_months(trunc(sysdate,'mm'),-3),'YYYYMM') and to_char(add_months(trunc(sysdate,'mm'),-1),'YYYYMM')
And to test:
select to_char(add_months(trunc(sysdate,'mm'),-3),'YYYYMM'),
to_char(add_months(trunc(sysdate,'mm'),-1),'YYYYMM')
from dual
/
TO_CHA TO_CHA
------ ------
201211 201301
SQL>
SY.
Published by: Solomon Yakobson on February 20, 2013 12:53
Tags: Database
Similar Questions
-
How to get the 'DAY' based on the territory of current account held a number between
Hi all
Looks like I'm at the end of my intelligence here but how to get the 'DAY' based on the territory of current account with a number between 1 and 7? Oracle has functions to extract the day of the week, but I can't find the other way around.
I need a way to know that the number '3' on the database with NLS_TERRITORY = AMERICA means a 'Tuesday' or the number '2' on a database with NLS_TERRITORY = GERMANY means "Tuesday" as well.SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production SQL> alter session set nls_territory=AMERICA; Session altered. SQL> select to_char (sysdate, 'D') from dual; T - 3 SQL> alter session set nls_territory=GERMANY; Session altered. SQL> select to_char (sysdate, 'D') from dual; T - 2
Hope I am clear enough.
And wish you all a happy new year :)
Kind regards
SmailUse the format "IW" to get the date of Monday and the format "DAY" to get the "first day of the week. Then compare dates to see if they are identical.
ALTER SESSION SET NLS_TERRITORY = 'AMERICA'; SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday", TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week", MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON" FROM DUAL CONNECT BY LEVEL <= 7; Monday NLS First day of week 1 if day 1 = SUN, 0 if MON --------- --------------------- -------------------------- 31-DEC-12 30-DEC-12 1 24-DEC-12 30-DEC-12 1 24-DEC-12 23-DEC-12 1 24-DEC-12 23-DEC-12 1 24-DEC-12 23-DEC-12 1 24-DEC-12 23-DEC-12 1 24-DEC-12 23-DEC-12 1 alter session set nls_territory = 'FRANCE'; SELECT TRUNC(SYSDATE-LEVEL, 'IW') "Monday", TRUNC(SYSDATE-LEVEL, 'DAY') "NLS First day of week", MOD(TRUNC(SYSDATE-LEVEL, 'IW') - TRUNC(SYSDATE-LEVEL, 'DAY') + 7, 7) "1 if day 1 = SUN, 0 if MON" FROM DUAL CONNECT BY LEVEL <= 7; Monday NLS First day of week 1 if day 1 = SUN, 0 if MON -------- --------------------- -------------------------- 31/12/12 31/12/12 0 24/12/12 24/12/12 0 24/12/12 24/12/12 0 24/12/12 24/12/12 0 24/12/12 24/12/12 0 24/12/12 24/12/12 0 24/12/12 24/12/12 0
Or it could be simpler:
ALTER SESSION SET NLS_TERRITORY = 'AMERICA'; WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7) SELECT INPUT_DAY, TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label" from data; INPUT_DAY Day label --------- ------------------------------------ 1 SUNDAY 2 MONDAY 3 TUESDAY 4 WEDNESDAY 5 THURSDAY 6 FRIDAY 7 SATURDAY alter session set nls_territory = 'FRANCE'; WITH DATA AS (SELECT LEVEL INPUT_DAY FROM DUAL CONNECT BY LEVEL <= 7) SELECT INPUT_DAY, TO_CHAR(TRUNC(SYSDATE, 'Day')+INPUT_DAY-1, 'DAY') "Day label" from data; INPUT_DAY Day label --------- ------------------------------------ 1 MONDAY 2 TUESDAY 3 WEDNESDAY 4 THURSDAY 5 FRIDAY 6 SATURDAY 7 SUNDAY
-
How to get the values based on the most recent date
Oracle Version 8i
How to get the new_value based on the most recent date
SELECT max (MODIFIED_ON), the Group LOG_ITEM_CHARACTERISTICS by MODIFIED_ON new_value - does not
Please, someone help me
CREATE TABLE LOG_ITEM_CHARACTERISTICS ( CHAR_LOG_ID NUMBER(10) NOT NULL, PIRM_ID VARCHAR2(8) NOT NULL, CONSTANT_FLAG VARCHAR2(1), CHARACTERISTIC_NAME VARCHAR2(25) NOT NULL, TYPE_NAME VARCHAR2(10) NOT NULL, NEW_VALUE VARCHAR2(3000), UOM VARCHAR2(10), MODIFIED_BY VARCHAR2(30), MODIFIED_ON DATE ) SET DEFINE OFF; Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187376, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '1', 'AMPS', 'EMPXD88', TO_DATE('10/25/1999 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187377, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMPXD88', TO_DATE('09/22/1998 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187378, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '0', 'AMPS', 'EMDXB88', TO_DATE('09/22/1998 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187384, '0307490N', 'N', 'OUTPUT CURRENT', 'PS2030/WVL', '2', 'AMPS', 'EMAXC29', TO_DATE('11/10/2000 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (187385, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55.1', 'VOLTS', 'EMAXC29', TO_DATE('10/19/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_ON) Values (2400742, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '2', 'AMPS', TO_DATE('10/19/2001 00:00:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (574093, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '2', 'AMPS', 'EMCTH88', TO_DATE('12/13/2002 11:55:16', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (574094, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMCTH88', TO_DATE('12/13/2002 11:55:16', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (3131486, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (3131487, '0307490N', 'N', 'LAST MEASURED DATE', 'PS2030/WVL', '16-12-04', 'DD/MM/YY', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (3131488, '0307490N', 'Y', 'POWER SUPPLY', 'PS2030/WVL', 'ESSENTIAL', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (3131489, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMCTH88', TO_DATE('12/16/2004 14:31:14', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (4759086, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (4759087, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '54.9', 'VOLTS', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (4759088, '0307490N', 'N', 'LAST MEASURED DATE', 'PS2030/WVL', '14/11/07', 'DD/MM/YY', 'EMRCT88', TO_DATE('11/15/2007 14:33:03', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6646012, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '5', 'AMPS', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646013, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646014, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6646015, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646016, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 12:56:17', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646057, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646058, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6646059, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'null', 'PAUL DEVERILL', TO_DATE('01/06/2011 13:03:18', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648577, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '6', 'AMPS', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648578, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6648579, '0307490N', 'Y', 'YR ROUTINES REQUIRED', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:35:45', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6648580, '0307490N', 'Y', 'BATT TEST SET AT 3M', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:36:00', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, MODIFIED_BY, MODIFIED_ON) Values (6648581, '0307490N', 'Y', 'CAP ALARM INHIBITED', 'PS2030/WVL', 'NULL', 'EMPXD88', TO_DATE('01/07/2011 13:36:10', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648634, '0307490N', 'N', 'MEASURED LOAD ON PER', 'PS2030/WVL', '5', 'AMPS', 'EMPXD88', TO_DATE('01/07/2011 13:51:06', 'MM/DD/YYYY HH24:MI:SS')); Insert into LOG_ITEM_CHARACTERISTICS (CHAR_LOG_ID, PIRM_ID, CONSTANT_FLAG, CHARACTERISTIC_NAME, TYPE_NAME, NEW_VALUE, UOM, MODIFIED_BY, MODIFIED_ON) Values (6648635, '0307490N', 'N', 'OUTPUT VOLTAGE', 'PS2030/WVL', '55', 'VOLTS', 'EMPXD88', TO_DATE('01/07/2011 13:51:06', 'MM/DD/YYYY HH24:MI:SS')); COMMIT;
user4587979 wrote:
Hi FrankYes, but I had more than 2 tables with item_characteristics, type_characteristics
If there are other tables involved, then CREATE TABLE and INSERT statements for them (for the relevant columns only). You must not post a lot of examples of data; usually just a couple of lines per table is enough to show the problem.
Also post the results desired from these data.What I try to do is, I'm comparing new_value in log_item_characteristics (whichever is most recent) with CHR_VALUE in the item_characteristics and the needs of different output values
I am trying to query is not giving desired out put
Point out some places where the output is wrong and explain how you get good results in these places, using specific examples from the data sample.
select lic.PIRM_ID, ic.CHR_ID, lic.CHARACTERISTIC_NAME, lic.TYPE_NAME, ic.CHR_VALUE, lic.NEW_VALUE, lic.MODIFIED_BY, lic.MODIFIED_ON, ic.CREATED_BY, ic.CREATED_ON,ic.MODIFIED_BY, ic.MODIFIED_ON from log_item_characteristics lic, item_characteristics ic,type_characteristics tc where lic.TYPE_NAME=tc.TYPE_NAME and lic.CHARACTERISTIC_NAME=tc.CHR_NAME and lic.PIRM_ID=ic.PIRM_ID and tc.CHR_ID=ic.CHR_ID and ic.CHR_VALUE <> lic.NEW_VALUE and lic.pirm_id in ('0307490N','0307521C') order by lic.pirm_id
Thank you; It is useful to see the existing query. Really, you have to format your code.
Please can you help me
What you've posted so far is like saying "I'm going 200 meters to the North, and then 500 meters East, but I'm not getting where I want to go." I would have a better chance to help you if you said, 'I'm out of my house, at 100, Elm Street and try to get to the supermarket at Broadway 279. I'm going 200 meters to the North... ', or, even better. "I want to buy a newspaper and some orange juice, so I thought I'd go to a convenience store. I start at my house, at 100, Elm Street... »
Always post some examples of data (CREATE TABLE and INSERT statements, as you did in your first post) and the desired results from these data. Explain how you get these results from these data. -
"How to change the gateway by default from the command prompt"
"How to change the gateway by default from the command prompt"
How to change the default gateway on the windows command line
-
How to get the usernames based on password_version in version 11g
Hi all
Are there opportunities to get user names based on password_version.
That is to say that I see for some users, the password_version is 10 g and others, is 10G 11 G. I'm looking to get the names of users who have the password_version 10 G 11 G.
Thank you
Hello
"SELECT * FROM dba_users where trim (password_versions) = ' 10 G 11 G.
Concerning
-
How to get these substrings based on the input string
Hi friends
I want the substring entered the string
the chain is something like this: 1234,3653,7684,3254,8777,987,234
now, I want to
the substrings between commas
can someone help me with this pls
in the first substring I need 1234
in the second, I need 3653...
so on until the end...
regardless of the channel is to the last
pls helpHello
You can do something like this:
SELECT txt , REGEXP_SUBSTR (txt, '[^,]+', 1, 1) AS part_1 , REGEXP_SUBSTR (txt, '[^,]+', 1, 2) AS part_2 , REGEXP_SUBSTR (txt, '[^,]+', 1, 3) AS part_3 -- ... FROM table_x ;
If there are less than n parts, then the technique above will not raise an error; It will just return null for part_n.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
Explain how you get these results from these data.
What you want if the entry is like this.
{code}
"foo, bar".
{code}
? You want to treat this as 2 pieces ('bar' is the 2nd) or a 3 s (the 2nd is NULL, and 'bar' is the 3rd)? Include examples in your sample data and results.
Always tell what version of Oracle you are using. -
How to pass arguments to the SQL Script in command prompt
I don't know about the ' & nom_de_variable "to request a value in the command line.
But, how can I pass arguments from the command line for the following script to the command - prompt
Example:
ex_proc. SQL
CREATE OR REPLACE PROCEDURE ex_proc (employee_id NUMBE IN)
IS
v_emp_id Number (38);
BEGIN
v_emp_id: = employe_id;
UPDATE emp_employee SET sal = 2000 WHERE emp_id = v_emp_id;
END;
/
call_ex_proc. SQL
Appellant for procedure above:
BEGIN
ex_proc (100); -The employee id is 100.
END;
/
Here are the General controls that we use to run the scripts above-
SQL > @ex_proc.sql
SQL > @call_ex_proc.sql
But my requirement is to pass the employee id as an argument in the command line as.
SQL > @call_ex_proc.sql 100
Is it possible to pass command line arguments?Usually this question start with reading documentation, wouldn't it?
Solomon Yakobson showed you the method gross and unreadable.
You will use best
set
= '& 1' '. -use &
in the rest of the code ----------
Sybrand Bakker
Senior Oracle DBA -
How to get the time based on the time zone?
Hi all
I try to get timestamp based on the time zone I assign in the computer... for example right now I m CA, if I change the time zone of the computer IS, and use time get Sec.vi, I always get time to CA.
and not the ACC at EST time... How can I get the time according to the time on my laptop?
Think I remember vaguely that LV reads this parameter when loading, then try to restart LV after changing the time zone and see if that helps.
-
How to get the month previous year?
Hello
I have to get the previous year three-months of the effective date, but I have a problem since the beginning of the year and it's because I set the incorrect query.
I mean:
I wrote this query
SELECT TO_CHAR(SYSDATE,'YYYYMM')-1, 2-TO_CHAR(SYSDATE,'YYYYMM'), TO_CHAR(SYSDATE,'YYYYMM')-3
FROM DUAL;
in order to get (on mars):
201502, 201501, 201412
but unfortunately, I get:
201502, 201501, 201500
Can you help me?
Thanks in advance!
Hello
Here's one way:
SELECT TO_CHAR (ADD_MONTHS (SYSDATE-1), "YYYYMM") AS the m1
, TO_CHAR (ADD_MONTHS (SYSDATE-2), "YYYYMM") AS m2
, TO_CHAR (ADD_MONTHS (SYSDATE,-3), "YYYYMM") M3
DOUBLE;
-
How to get every month with SQL query?
Hello world
I want to display every month (Jan-Dec) in the 1st column and their leaders in the 2nd column, but that there is no record in JAN, Feb and March, while they do not come to the top.
Can someone please help me get JAN, FEB etc with leaders like 0?I know it's possible with the NVL function, but I don't know where to put it.
I'm really grateful for help you.
Thanks in advance.
I use oracle 10g on Windows XP.[code]
SELECT ".
CASE
WHEN b.mon = '01' THEN 'JAN' WHEN b.mon = '02' THEN 'FEB' WHEN b.mon = '03' AND 'MAR '.
WHEN b.mon = '04' THEN "APR" b.mon = WHEN '05' CAN '' MAY '' WHEN b.mon = '06' THEN 'JUN '.
WHEN b.mon = '07' THEN 'JUL' WHEN b.mon = '08' and THEN 'AUG' WHEN b.mon = '09' AND 'MS '.
WHEN b.mon = '10' and 'OCT', THEN WHEN b.mon = '11' and THEN 'NOV' WHEN b.mon = '12' AND 'DEC '.
END of month
count (*) NTC
Of
(Con.fst_name SELECT first_name, con.last_name, usr.login, USER_ID,)
App.appl_src_cd Registration_Source, to_date(usr.created,'DD-MON-YY') Created_Date,
To_char(usr.created,'MM') Lun
of usr, con siebel.s_contact siebel.s_user, siebel. S_PER_PRTNRAPPL app
where con.par_row_id = usr.row_id
and app.row_id = con.row_id
and app.appl_src_cd = 'Siebel eService.
AND TO_CHAR (usr.created, 'YYYY') =: P415_YEAR
) b
B.mon group
order by 3 desc
[/ code]
Now get the output voltage...
MONTH CNT APR 4818 JUL 4543 JUN 4295 MAY 4190 AUG 541 MAR 20 What Jan, Feb, March etc in there too with the County under the name of 0.
SELECT TO_CHAR (TO_DATE (b.mon, 'mm'), 'MY') month.
Count ()) - 1 cnt
DE)
Con.fst_name SELECT first_name,
con.last_name,
usr. Login, USER_ID,
App.appl_src_cd Registration_Source,
to_date(usr.created,'DD-mon-YY') Created_Date,
To_char(usr.created,'MM') Lun
OF siebel.s_user usr.
Con Siebel.S_CONTACT,
Siebel. S_PER_PRTNRAPPL app
WHERE con.par_row_id = usr.row_id
AND app.row_id = con.row_id
AND app.appl_src_cd = 'Siebel eService.
AND TO_CHAR (usr.created, 'YYYY') =: P415_YEAR
UNION ALL
SELECT null,
NULL,
NULL,
NULL,
NULL,
LPAD(Level,2,'0')
OF the double
CONNECT BY level<=>=>
) b
GROUP BY b.mon
ORDER BY DESC 3
SY.
-
How to get the process based on the correlation instance?
Can someone please help me get all the process/sub-sub-process color based on the correlation.
Is there some API available with the method like getProcessByCorrelation()Dude,
First approach:
public getInstanceByCorrelation (String processId InstanceInfo,
String correlationName,
Object [] correlationValues)
survey OperationExceptionGets the instance specified by the process id, alias and the correlation values.
Correlations defined during the Argument mapping in the Studio. Unlike the arguments, there is no way to retrieve the name of correlation or values programmatically.For this you must have ProcessServiceNESession.Please below the list of the api
http://eDOCS.beasys.com/albsi/docs57/papijavadoc/Fuego/PAPI/ProcessServiceNESession.htmlSecond approach:
You can also use under method in ALBPM to findCorrelation
instanceId = Correlation.findInstanceBy (name: "", values: {});
Once the correlation is found, it will return u the instanceId of instanceId.From you can do what you want. Once again your fitness questions -
How to get 4 months of sales data
Hello guys
I have the Sales table
Time by the month sales management
201501 10 100
201502 10 20
201503 10 90
201504 10 90
Acually I found this formula Time.Date < = cast (current_date- date) and Time.Date > = TIMESTAMPADD (SQL_TSI_MONTH,-3, TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH ( CURRENT_DATE) *-(1) + 1, CURRENT_DATE))
My question: is it for using the DATE, in fact, my time dimension is working hour per month? Current_date can be replaced by @{pvMonth} {2015-05}.
You cannot directly replace CURRENT_DATE (a date object) with @{pvMonth} {2015-05} because it is just a piece of text, not a date. So you must first create your varchar date and then you can use in date/time formulas.
-
How to get the maximum disk size for a powershell prompt
Hi guys
I tried all day to get the value of the maximum disk size allocated to a virtual machine. Using get - view I can see the actual size of disc but when I look at VM via 'Edit Machine' I see ' hard disk 1' ability to 40 GB and and size maximum (GB) to 97.5 - How do I get this maximum size via powershell?
See you soon
Sparky
Near there, it is actually the amount of free space on the data store over the current size of the hard drive.
With this script, you can calculate the value
foreach($dev in (Get-VM
| Get-View).Config.Hardware.Device){ if($dev.DeviceInfo.Label -like "Hard Disk*"){ $dsFree = (Get-Datastore (Get-View -Id $dev.Backing.Datastore).Info.Name).FreeSpaceMB $diskSize = ($dev.CapacityInKB / 1Kb) $MaxSize = $dsFree + $diskSize Write-Host "Maximum size for" $dev.DeviceInfo.Label "=" ("{0:f2}" -f (($dsFree + $disksize)/ 1Kb)) "Gb" } } -
How to get invoice_id ap for the invoice number
Hello
How to query the table of ap_invoices_v by the number of the invoice instead of invoice_id
or, how to get the invoice_id based on invoice number and type
appriciate your help
Hello
Use the where clause:
where invoice_num = "invoice #
and invoice_type = 'inv type.
Kind regards
Bashar
-
How to save passwords after you said 'no' to the command prompt
How save passwords after you said 'never' at the command prompt.
I tried again and again and again, and none of the solutions suggested on the internet works. And there is also something too complicated for me.
Hi, jscher2000:
Yes it's MARKET! Thank you very much for your help!
I'm not all pages to remember my password I just want some specific pages to remember passwords. for example. for now I only need craigslist login page to remember my pw, not other login pages.
If this is the case, then it is a perfect solution for me.
Maybe you are looking for
-
just Commonw bought this laptop from pc world but have no sound. I tried to reinstall the drivers from the disk utilities and restored the drivers in Device Manager, but still no sound.Could someone tell me where I could download them, etc.
-
ATV4 shows more the content of the Description tab?
I do not understand why the AppleTV was to change the display of metadata of film of the 'Description' in the 'Comment' [iTunes 12.3.x details tab] field in the 4th gen AppleTV. Swear next to the words I uttered when I realized that all my work to e
-
P6-2330 HP: HP p6-2330 change from windows to windows 7 pro 8.1
Im going to change my hard drive to an SSD. I hjave a disc for Windows 7 Pro OEM, if I install it on my new ssd will work on a computer(p6-2330) that came with 8 windows of the factory
-
reset the taskbar at the bottom of the screen
I accidentally moved my taskbar to the left. I tried all the suggestions on how to reset to the initial position, but most of the answers are for Windows, Windows XP but not Vista. Any help is appreciated.
-
Dear, I have Sony Z2, it is the original charger to electricity is 1.5 a. I bought a food bank that has only 2 plugs (1A and 2A). Which plug should I plug my laptop in? Thank you.