Display lines of dates in the column
Hello
I use 12 c DB.
Database Oracle 12 c Enterprise Edition Release 12.1.0.1.0 - 64 bit Production
PL/SQL Release 12.1.0.1.0 - Production
"CORE 12.1.0.1.0 Production."
AMT for 64-bit Windows: Version 12.1.0.1.0 - Production
NLSRTL Version 12.1.0.1.0 - Production
I wrote under request, I want to display these lines in columns... How can I do?
Select to_date (1 January 2013 "") + level 1 double dte
connect by to_date (January 1, 2013 ',' MON-DD-YYYY') + level 1 < = last_day (to_date (January 31, 2013 ',' MON-DD-YYYY ""));
Thank you.
As already suggested by
Select *.
from (select level lvl, dates "2013-01-01' + level - 1 dte)
of the double
connect by level<= last_day(date="" '2013-01-01')="" -="" date="" '2013-01-01'="" +="">=>
)
Pivot (max lvl in (d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, 10 9 8 7 6 5 4 3 2 1 (dte)
11 as d11, d12, d13, d14, d15, d16, d17, d18, d19, d20, 20 19 18 17 16 15 14 13 12
21 as d21, d22, d23, d24 24 23, 25 as d25, 26 as d26, d27 27, 28 d28, d29 29, 30 as d30, 22
31 as d31
)
)
Concerning
Etbin
Tags: Database
Similar Questions
-
How to display rows of data in different columns?
I'm new to SQL and currently, that's what I try to do:
Display multiple lines of data in different columns in the same row
I have a table like this:
CREATE TABLE TRIPLEG)
T # NUMBER (10) NOT NULL,
STEP # NUMBER (2) NOT NULL,
DEPARTURE VARCHAR (30) NOT NULL,
VARCHAR (30) DESTINATION NOT NULL,.
CONSTRAINT TRIPLEG_PKEY PRIMARY KEY (T #, LEG #).
TRIPLEG_UNIQUE UNIQUE CONSTRAINT (T #, DEPARTURE, DESTINATION).
CONSTRAINT TRIPLEG_FKEY1 FOREIGN KEY (T #) REFERENCES TRIP(T#));
INSERT INTO TRIPLEG VALUES (1, 1, 'Sydney', 'Melbourne');
INSERT INTO TRIPLEG VALUES (1, 2, 'Melbourne', 'Adélaïde');
The result should be something like this:
> T # | ORIGIN | DESTINATION1 | DESTINATION2
> 1 | SYDNEY | MELBORUNE | ADELAIDE
The request must include the ' COUNT(T#) < 3' since I only need to display the records of less than 3. How can I get the results I want to use relational views?
Thank you!!!
I replaced the syntax "where" with the syntax 'account '. The reason why I do this is because I want to only display records with a number of travel of less than 3. By defining where the legs #.<=3, the="" result="" will="" be="" all="" the="" records="" of="" the="" tripleg="" table="" since="" each="" record="" could="" also="" have="" leg#="" is="">=3,>
The answer is:
with t as (SELECT t #,)
REGEXP_REPLACE)
LISTAGG (start |) '->' || destination, ' ')
THE Group (ORDER BY t #, leg #).
'([^ ]+) \1+',
"\1") str
OF tripleg
HAVING COUNT (T #)<>
GROUP BY t #)
Select T #, regexp_substr (str, ' [^->] +', 1, 1) departure
, regexp_substr (str, ' [^->] +', 1, 2) destination_1
, regexp_substr (str, ' [^->] +' 1, 3) destination_2
, regexp_substr (str, ' [^->] +' 1, 4) destination_3
Thanks to Marty and knani!
-
How to remove tabs, several spaces, quotes from data in the column.
Hello
How can we remove legs, several spaces, quotes from data in the column.
Entry:
H ope you 'are' Ingo w ell
Output:
H ope do you everything - there is a tab in hope and double-spaced in the well. This should be replaced by space. (Tab and multi spaces)
I found myself with below:
REGEXP_REPLACE (REGEXP_REPLACE (Replace (col, Chr (9),' '), ' () {2,} ', ' '),'[' ""]', ")
Can we do more efficiently, your contributions are appreciated.
I tried
REGEXP_REPLACE (col,'[^ [a - z, A - Z, 0-9, Chr (0) - Chr (127) [: Space:]]] *', ") but the tabs still exist and that my data have German characters I can't go along with this.
Thank you
GVK.
Hello
Karthik417 wrote:
Hello
Thanks for your suggestion. In the above expression, we still missed to replace the double quotes.
So thought we must use another regular expression instead of REPLACE.
Select REGEXP_REPLACE (REGEXP_REPLACE (' H ope you "are" d "Ingo ell w ',' [' |])) CHR (9) | + ',' '),'["" "]') twice;
I suppose we must use at least 2 REGEXP to achieve and cannot get it with a single expression.
Thank you
Sorry, I removed single quotes, not double - quote. (This shows one of the reasons why having a few lines of sample data is very useful).
I think you don't need 2 separate functions. I do not think that the two must be REGEXP_REPLACE; You can use TRANSLATE to remove both types of quotation marks in a single function call:
TRANSLATE (REGEXP_REPLACE (col
, '[ ' || CHR (9) | ']+'
, ' '
)
, '?'''"',
, '?'
)
Of course, you can use use REGEXP_REPLACE to remove the quotes, if you really want to.
Powerful they are, regular expressions are basically only 1 thing, things not 2 or more different. Sometimes, he can watch as they do several things, because they can operate on character classes, like the series containing the
and the and a variable number of characters. For example, the REGEXP_REPLACE function, I used above is simply changing expression expression x y, where x is 1 consecutive or more characters of a given set. As we both demonstrated, we can have a separate function that changes from p to q, but I know not all built-in function which, in general, can change x to y at the time that it changes from p to q. TRANSLATE comes close, but TRANSLATE only works if x, y, p and q are single (or NULL), characters not expressions. -
How to assign the text value when the data in the column is null or empty
Hello guys
I have a small question
I have a column A that half of its value is empty, now the condition is that whenever the column is empty, assign "N/a" in the column... So I wrote a code which is:
<? If: not (column A)? > column a = 'n/a' <? end if? >
However, when I preview the RTF model, the data in the column still has not changed at all, many lines are still empty and did not show 'n/a '... The column is of type text
Please advice
Thank youN/A
-
Hello
I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships
Details of the table
Alert-1 - AlertCode (FK), AlerID (PK)
2 AlertCode-AlertDefinition-(PK)
Help, please
----------
Hi Vincent,.
I think that you have not worked on adf 12.1.3. In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link
---
-
I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format. How can I get the pdf data into the columns and rows so that I can do the calculations?
If you start the https://forums.adobe.com/welcome Forums Index
You will be able to select a forum for the specific Adobe products you use
Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll
-
I need to display tomorrow's date in the format ' yyyy/mm/dd' in Captivate 8.
I need to display tomorrow's date in the format ' yyyy/mm/dd' in Captivate 8.
I understand that I must build a tip for this Action. Has someone done something similar and can post a screenshot of the completed tip Action?
Thanks in advance!
I think that means Lieve this article:
http://www.Infosemantics.com.au/Adobe-Captivate/template/02-dynamic-date-functions
-
How to divide the data in the column based identifier
Hello
I use the oracle database.
I have data in this format in my column 1234 ~ 2345 ~ 3456 ~ 4567.
I need a motion to split the data in the column based on the identifier ' ~', so that I can choose the value after the second occurrence of the identifier.
Do I know who can do this.
Published by: 962987 on October 3, 2012 12:11Hello
Welcome to the forum!
Whenever you have any questions, please post CREATE TABLE and INSERT statements for some examples of data and the results desired from these data. For example, in view of these data
CREATE TABLE table_x ( my_column VARCHAR2 (40) ); INSERT INTO table_x (my_column) VALUES ('1234~2345~3456~4567'); INSERT INTO table_x (my_column) VALUES ('just~2 parts');
I think you're asking for these results
PART_3 MY_COLUMN ---------- ---------------------------------------- 3456 1234~2345~3456~4567 just~2 parts
I suppose that, if the string does not contain at least 2 ' ~ s, you want to return null. It's a good idea to explain what you want like that for special cases and include examples in your sample data and results.
Not all versions of Oracle are exactly the same. In fact, they are all different. If you want the best solution that works with your version, then say what version it is.
The following query will work in Oracle 10.1 and higher:SELECT REGEXP_SUBSTR ( my_column , '[^~]+' , 1 , 3 -- 3rd occurrence (after 2nd delimiter) ) AS part_3 , my_column -- if wanted FROM table_x ;
See the FAQ forum {message identifier: = 9360002}
Published by: Frank Kulash, October 3, 2012 15:24
Adding sample data and results. -
How to group data in the column?
Hi all
Anyone can solve the my problem please?
I have two columns 'Age' and 'employee ID '.
I want the 'Number of employees' group for the specific AGE group:
Age | Number of employees
20 to 30 | 06
31 to 40. 13
41 to 50. 16
51 to 60. 03
And the data in the columns are put aside
Age | Employee IDS
30. 002
38. 008
33. 298
22. 213
54. 083
24. 098
So now.
Waiting for your HELP.
In advance thank you very much...
Take careHere you go...
Drag a column of answers and name as age and in his writing of fx
case
When tablename.age between 20 and 30 then 20 to 30'
When tablename.age between 31 and 40 and 31 to 40'
When can tablename.age between 41 and 50 41 to 50'
When tablename.age between 51 and 60 and 51 to 60'
endDrag a column of answers and name it as "Number of employees" and in his writing of fx
Count (tablename. (EmployeeID)
That would give you the report of your choice
I hope that its useful...
Thank you
Ashish Gupta -
the data in the column sql colorization
Please help predict the data in the column of blue and underlined.
I wanted to add in sql only.
How can I addselect decode(TUFF_GENERIC_PKG.adj_status_func(m.billing_key),'Y','<a href="javascript:alert(''This billing period has an open adjustment request currently pending'')">'|| to_char(to_date('01/'||trim(substr(M.REPORT_PERIOD,5,2))||'/'|| trim(substr(M.REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') ||'</a>','<a href="f?p=&APP_ID.:5:&APP_SESSION.:BRANCH:NO: 5:P5_BILLING_KEY:'||m.billing_key||'">'|| to_char(to_date('01/'||trim(substr(M.REPORT_PERIOD,5,2))||'/'|| trim(substr(M.REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') ||'</a>') from dual;
Hello
Adding style to html (a tag) in your query
Kind regards
Jari -
SQL queries for reports help: need to reverse the data in the column in columns [O
Hi all
I'm looking for help in writing SQL, where I need to reverse the data in the columns column.
My data in DB is as below.
VALUE OF NAME OF MONTH
Jan-10 M1 5
Jan-10 M2 8
Jan-10 M3 9
Feb-10 M1 4
Feb-10 M2 6
Feb-10 M3 2
M4 10 Feb 10
M1 10 Mar 21
Mar-10 M2 6
Power required for the declaration will be like:
MONTHS M1 M2 M3 M4
Jan-10 5 8 9
Feb-10 4 6 2 10
21 Mar-10 6
How can I do this using SQL. [ORACLE 10g]?
I can make use of server Oracle BI also.
Please help me on this...I think this is wrong forum to ask this question. You want to do it in OBIEE or at the DB level. In oBIEE you can do in a table privot view.
Thnaks,
Knani -
Transform the data in the column marked in lines
I've already implemented Tom Kytes solution for dynamic / variant in the list that is found here and on his own works very well when passing a variable. I'm trying to use it to decode several rows in a table. Each row has a column of delimited data and I want to turn these data delimited by lines.
Here is the configuration.
create table data_source
(upload_id number not null,
data_source_id integer not null,
sources varchar2 (50).
ERROR_MESSAGE varchar2 (100)
);
insert into data_source (upload_id, data_source_id, sources) values (1, 1, 'a');
insert into data_source (upload_id, data_source_id, sources) values (1,2, 'A:B:C:X');
insert into data_source (upload_id, data_source_id, sources) values (1, 3, 'c');
insert into data_source (upload_id, data_source_id, sources) values (1, 4, 'B');
insert into data_source (upload_id, data_source_id, sources) values (1.5, 'Y');
create the table data_source_lookup
(varchar2 (10) sources non-null)
;
insert into data_source_lookup (sources) values('A');
insert into data_source_lookup (sources) values('B');
insert into data_source_lookup (sources) values('C');
My goal is to update the table data_source for lines where there is an invalid data source, in the example above that would be 2 and 5 lines. I can do this individually using the in_list solution:
Select * from table (in_list ('A:B:C:X',' :'))))
If column_value not in (select data_source_lookup sources)
Returns 'X' as expected.
What I am struggling with is a method to make it through all the lines for a given loading ID:
Update data_source
ERROR_MESSAGE = "Source of data" is not a valid value
where upload_id = 1 and...
I tried to create a join cross- like this:
Select ds.data_source_id, ds.sources, x.column_value
DS data_source cross join (select column_value in the table (in_list (ds.sources,' :'))) x)))
but as you can imagine passing in the function ds.sources has failed, returning "ORA-00904:"DS".» "SOURCES": invalid identifier.
I'm sure I can solve this problem in a loop, but that seems inefficient. Anyone know of a method by which I can pass the content of the column to the table function (in_list ()) for each line?
For someone else it may call a function table in several lines, here's what I came with. First of all, I changed my data to test a bit to add some very incorrect values.
setting a day from sources set data_source = 'A:B:C:X:Y' where data_source_id = 1;
This query will not return a list of lines that contain invalid values, including their wrong value:
Select the rowid, sources, column_value
de)
Select the rowid, data_source sources)
x cross table junction (utils.in_list (x.sources,' :'))))
where column_value is not null
and not exists (select null from data_source_lookup l where l.sources = column_value)
AABk3MAAjAAAKd8AAA A:B:C:X:Y X
AABk3MAAjAAAKd8AAA A:B:C:X:Y Y
AABk3MAAjAAAKd8AAB A:B:C:X X
AABk3MAAjAAAKd8AAE Y Y
With this work, I can then modify cela a little bit to turn it back in a delimited list bad values that I can put in the error column.
Update data_source x 2
ERROR_MESSAGE = value
(by selecting bad_value in)
Select RID, "Invalid Data Source - ' |" listagg(column_value,':') within the Group (column_value control) bad_value
de)
Select the rowid RID, data_source sources)
x cross table junction (utils.in_list (x.sources,' :'))))
where column_value is not null
and not exists (select null from data_source_lookup l where l.sources = column_value)
(Group of RID) where rid = x 2 .rowid)
where x 2 .upload_id = 1
and x2.rowid in (select RID)
de)
Select the rowid RID, data_source sources)
x cross table junction (utils.in_list (x.sources,' :'))))
where column_value is not null
and not exists (select null from data_source_lookup l where l.sources = column_value))
;
It works well, and I find myself with:
Error sources
Source of invalid data in A:B:C:X:Y - x: y
Invalid Data Source - X A:B:C:X
C
B
Valid source of data Y - Y
-
transpose the data in the column to the line
I want to change the columns in lines, my data is
TYPE RANK 1 A 1 AA 1 AAA 2 B 2 BB I want it in
RANK (1) RANK (2) A B AA BB AAA Please help me
Thanks for the response guys, in the meantime, I found the solution too
SELECT MAX(CASE WHEN ID=1 THEN RATING ELSE NULL END) AS RC,
MAX(CASE WHEN ID=2 THEN RATING ELSE NULL END) LAUGHED
FROM (SELECT ID, RATING, ROW_NUMBER() over (ORDER BY rowid ID PARTITION) RN)
OF RANK_TEST) X
GROUP BY RN;
Thank you very much
-
display the data in the column as column name
in this column of query names are hard coded, I need to display the column name dynamically (based on sysdate). Please help me on this?
with test_emp as
(select 100 empno, 1st February 2014 ' hiredate, SAL union 1000 double all the)
Select 200 empno, February 3, 2014 ", 2000 union SAL double all the"
Select empno 300, 4 February 2014 ", 3000 union SAL double all the"
Select 400 empno, 5 February 2014 ", 4000 SAL double
)
-Select * from test_emp
SELECT EmpNo,
Sum (decode (HireDate, trunc (sysdate), SAL, 0)) as '4 February 2014. "
Sum (decode (HireDate, SAL, trunc(sysdate-1), 0)) as "February 3, 2014.
Sum (decode (HireDate, trunc (sysdate)-2, SAL, 0)) as 'February 2, 2014.
Sum (decode (HireDate, trunc (sysdate)-3, SAL, 0)) as 'February 1st, 2014. "
Sum (decode (HireDate, trunc (sysdate)-4, SAL, 0)) as 'January 31, 2014.
OF test_emp
Group by empno stopped by 1
expected results:
EMPNO February 4, 2014 3 February 2014 2 February 2014 February 1, 2014 January 31, 2014
100 0 0 0 1000 0
200 0 2000 0 0 0
300 3000 0 0 0 0
400 0 0 0 0 0
Hello..
We cannot manage dynamic crossover into a sql. So what I did just create a function with refcursor and get results. It will work for your case only. Try the code below and let me know in case of any problems
FUNCTION to CREATE or REPLACE dyn_row_colum
RETURN SYS_REFCURSOR
AS
v_sqlstr VARCHAR2 (32767): = ' SELECT empno, SUM (DECODE (hiredate,'|)) '''|| Trunc (sysdate) | " ((' |', sal, 0))' | ' '||'"'|| TRUNC (SYSDATE) |' » ' || «, » ;
v_rfcur SYS_REFCURSOR;
BEGIN
FOR j_rec IN (SELECT col_val FROM test_emp TRUNC(SYSDATE-ROWNUM))
LOOP
v_sqlstr: = v_sqlstr | » '||' SUM (DECODE (hiredate,'|)) '''|| j_rec.col_val | " ((' |', sal, 0))' | ' '||'"'|| j_rec.col_val |'"' | ',';"
END LOOP;
v_sqlstr: = RTRIM (v_sqlstr, ','). » '||' OF test_emp GROUP BY empno';
V_rfcur OPEN FOR v_sqlstr;
RETURN v_rfcur;
EXCEPTION
WHILE OTHERS THEN
LIFT;
END dyn_row_colum;
VARIABLE v_cur REFCURSOR
EXEC: v_cur: = dyn_row_colum;
PRINT v_cur;
SELECT dyn_row_colum FROM dual;
Unit tests: -.
----------------
Scott@ORCL > dyn_row_colum FUNCTION to CREATE or REPLACE
2 SYS_REFCURSOR RETURN
3 AS
4 v_sqlstr VARCHAR2 (32767): = ' SELECT empno, SUM (DECODE (hiredate,'|)) '''|| Trunc (sysdate) | " ((' |', sal, 0))' | ' '||'"'|| TRUNC (SYSDATE) |' » ' || «, » ;
5 v_rfcur SYS_REFCURSOR;
6 BEGIN
7 FOR j_rec IN (SELECT col_val FROM test_emp TRUNC(SYSDATE-ROWNUM))
8 LOOP
9 v_sqlstr: = v_sqlstr | » '||' SUM (DECODE (hiredate,'|)) '''|| j_rec.col_val | " ((' |', sal, 0))' | ' '||'"'|| j_rec.col_val |'"' | ',';"
10 END OF LOOP;
11 v_sqlstr: = RTRIM (v_sqlstr, ','). » '||' OF test_emp GROUP BY empno';
12 v_rfcur OPEN FOR v_sqlstr;
13 RETURN v_rfcur;
14 EXCEPTION
15 SO THAT OTHERS THEN
16 RAISE;
17 END dyn_row_colum;
18.
The function is created.
Scott@ORCL > v_cur VARIABLE REFCURSOR
Scott@ORCL > EXEC: v_cur: = dyn_row_colum;
PL/SQL procedure successfully completed.
Scott@ORCL > v_cur PRINT;
EMPNO 5 FEBRUARY 14 FEBRUARY 4, 14 3 FEBRUARY 14 FEBRUARY 2 14 1 FEBRUARY 14
---------- ---------- ---------- ---------- ---------- ----------
100 0 0 0 0 1000
400 4000 0 0 0 0
300 0 3000 0 0 0
200 0 0 2000 0 0
Scott@ORCL > dyn_row_colum SELECT FROM dual;
DYN_ROW_COLUM
--------------------
CURSOR STATEMENT: 1
CURSOR STATEMENT: 1
EMPNO 5 FEBRUARY 14 FEBRUARY 4, 14 3 FEBRUARY 14 FEBRUARY 2 14 1 FEBRUARY 14
---------- ---------- ---------- ---------- ---------- ----------
100 0 0 0 0 1000
400 4000 0 0 0 0
300 0 3000 0 0 0
200 0 0 2000 0 0
-
copy the data from the columns box
Hi all, I have multicolumn listbox and I deleted all the lines both vertical and horizontal lines and columns headers.when while, I run my vi, some string data are introduced into the list box. However when I try to copy a line of string in the drop-down list, I am unable to do (I can't select a line,... the idea is to select a row in the list box so that I can paste it somewhere else... That's how am supposed to allow some feature of the list box to be able to do this... any help? Thanks already
Hello
If I understand your problem, you want to copy the values of time and the description at once and paste the entire line in a txt for example, no? Unfortunately, the listbox is as an array of 2D channels and each field is a different value of this table 2D. You can copy a value at the time when the VI does not RUN otherwise you can use a property node to display the name of items and that the copy and paste values (always a time value) also using the VI.
I hope the information is useful for your application
Concerning
Mario
Maybe you are looking for
-
I can FCPX on a MacBook Air?
Hello In fact, not me, but a friend. An artist friend needs a computer for the usual things but I would also like to make small films as she wishes. She doesn't have much money, so, in research on Mac products, which is a stretch but perhaps at hand
-
It is constant flickering or flashing on the pages.
It's so boring. The flicker of the web pages or blink especially when the cursor is went on top of the Web page where the toolbar, shortcuts and open tabs are. Sometimes it flashes even if the mouse is not used. Some suggestions that I have tried are
-
I can't recover my address, bookmarks bar, back button, button refresh etc. that disappeared This has happened Each time Firefox opened is 2 months ago
-
Satellite A660 (PSAW3A-07U00R) - error recovery
MySatellite A660 i7 1.73GHz with Windows 7 now hang at startup. When I rebooted I get to start Windows in safe mode or run Startup Repair. The two option to hang on. I also sometimes get ERROR: F3-F100-0003. I used my recovery disks (that I have used
-
Ideas: Programma u lapses problems encountered Foutberichten recent p die u aan uw computer Wat I al geprobeerd om het op clean would you lossenDon't forget not - says is een openbaar due forum private information such as e-mail the telefoonnummers b