How to 'show' a static pseudo index using SQL statement select?
Hello again,I have to post a time of 24 hours as an index. (00:00 - 23:00)
It's easy, if data are available.
But, if the data are not regularly exist on specific time (the time is not regular, IE: 00:00, 01:00, 05:00, 08:00, 10:00, 11:00, 23:00), then it of OK for a TABLE, but not for a CHART.
Here is the story:
I've written a SQL statement that can 'choose' what to display respectively the time available. The result will appear on the map: days or the time is used for the x-axis and the respective value on axis y.
Example:
+ If the data consists of 'days' (ie: the last 5 days from now on, 16/07/2012, 17/07/2012, 18/07/2012, 19/07/2012, 20/07/2012), the chart will display these dates on the x-axis.
+ If the data consists of 'hours' (ie: only 1 day, hour 00:00 - 23:00), then the chart shows the hours on the x-axis.
If the 'hours' are not regular, means: there is no data on the specific hours, the result of the query is not as regular, average: the value of X - axis "jumps" irregularly.
Question:
Is it possible to interrogate our own static value?
for example:
Select 'Hello' from dual-> result: 'Hello', 1 column, 1 line
But how to display it into several lines, i.e.:
Time
*****
0
1
2
3
4
5
...
...
23
Note:
the x-axis on the graph model can be customized only for 1 single mode, example: 'Days',
but of course it will not appear correctly if the result of the query are "hours."
This means: I have to find the workaround on the SQL query.
DB: ORA 11
Thank you and best regards.
You can generate mulltiple rows if you use LEVEL and CONNECT BY:
SQL> select level
2 from dual
3 connect by level <= 10;
LEVEL
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> select sysdate+level-1
2 from dual
3 connect by level <= 10;
SYSDATE+LEVEL-1
-------------------
20-07-2012 12:48:26
21-07-2012 12:48:26
22-07-2012 12:48:26
23-07-2012 12:48:26
24-07-2012 12:48:26
25-07-2012 12:48:26
26-07-2012 12:48:26
27-07-2012 12:48:26
28-07-2012 12:48:26
29-07-2012 12:48:26
10 rows selected.
SQL> select to_char(trunc(sysdate), 'hh24')+level-1
2 from dual
3 connect by level <= 24;
TO_CHAR(TRUNC(SYSDATE),'HH24')+LEVEL-1
--------------------------------------
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 rows selected.
Tags: Database
Similar Questions
-
How to analysis of the XML in the sql statement?
Hi friends, I have a table that contains a column of type CLOB, stores in xml format. For example, the data are like that
<Employees xmlns="http://TargetNamespace.com/read_emp"> <C1>106</C1> <C2>Harish</C2> <C3>1998-05-12</C3> <C4>HR</C4> <C5>1600</C5> <C6>10</C6> </Employees>
So how can I write the sql statement for the analysis of the data at the top
create or replace procedure parsing_xml
(
clob trans_payload
trans_dir varchar2
)
as
Start
if(trans_dir='inbound/emp')
then
insert into emp_proj
(
employee_id
last_name
hire_date
job_id
salary
department_id
)
Select t1.c1
t1.c2
t1.c3
t1.c4
t1.c5
t1.c6
from xmltable
(
XmlNamespaces ('http://TargetNamespace.com/read_emp' as 'emp').
' / ' emp:Employees by the way of xmltype (trans_payload)
columns
whole path of C1 'emp:C1. "
path of varchar2 (10) C2 'emp:C2. "
C3 varchar2 (10) path "emp:C3."
C4 varchar2 (10) path "emp:C4."
whole path of C5 "emp:C5."
C6 varchar2 (10) path 'emp:C6 '.
) t1;
end if;
commit;
end;
-
How to see all passed to the db sql statements?
Is it possible to configure Jdevloper (11.1.1.4) in a way so that it shows all the sql statements in the console?
THX in advance
You have restarted your WLS instance in debug mode?
-
How to get the static attribute by using its name as a string
I have an app with about 100 boxes of single drop-down list (this is a requirement of the Government, I'm not that bad a designer) and I would like to define the choices in a single file separated like this:
package components {}
Import mx.collections.ArrayCollection;
public class {choice}
[Bindable] public static var A0310A: collection ArrayCollection = new ArrayCollection ([] collection
{value: '01', label: 'Admission'},
{value: "02", label: "Quarterly"},
.. .snip...
([{value: "99", label: "NOT the OBRA required"}]) ;
public static void getChoices(name:String):ArrayCollection {}
var temp: ArrayCollection = collection?
Return temp;
}
}//----------------end of class--------------------------------
}//======================== end of package==============================I want to use it like this
< my: ComboBox id = "mdscombo" tag = "A0310A" / >
Where the definition of my: ComboBox includes the code like this
var zz:ArrayCollection = Choices.getChoices (name);
but I can not find any function that will allow me to do. I don't want really clutter up the code by creating a name-> object mapping table.
I had also considered using the XML data type, but I have the same question, unless I had all the choices under a single root (possible), but this could be a nightmare when debugging in typo XML file.
Any suggestions?
To answer your question, you can access static variables with a chain in this way:
Choice ["A0310A"]
However, you probably want to re-evaluate your design because this isn't a very desirable approach.
-
Use SQL statements to roll a calendar forward to a random date
Hello
Oracle 10.2.0.4 Linux
We have two tables largeish (10 ^ 5 rows each) who follow our planned workforce hours. The first table created generic programs that show the days, at that each must have Schedule 1-n lines in this document, one for every day of the cycle. The majority of our workforce is on a 8 day cycle. In the example below, I have two shifts
Sched_4d it is a cycle of four days from the day - the day pairs off.
Sched_3d cycle this is a full day off, half day, day off.
According the information below you can see that in 1990, the sched_4d went to a day of 8 hours to 9 hours a day. There is no guarantee that SCHED_4D will not win suddenly 2 additional days in this years union negotiations.
The second table is a simple assignment table when a person goes on a calendar.
To determine the schedule for the day a datum, you look at the table EMP_SHIFT to determine which calendar is 'in progress', then you look at the date at which the person has been assigned to the planning and guess that's SHIFT_ID 1, the next day is SHIFT_ID 2 until complete you the cycle and try again.
CREATE TABLE SCHED_DATA
(
SCHED_ID VARCHAR2 (8 CHAR) NOT NULL,
ASOFDATE DATE NOT NULL,
SHIFT_ID NUMBER (3) NOT NULL,
SCHED_HRS NUMBER (4,2) NOT NULL
)
;
CREATE UNIQUE INDEX SCHED_DATA on SCHED_DATA (SCHED_ID, ASOFDATE, SHIFT_ID)
;
CREATE TABLE EMP_SHIFT
(
EMPID VARCHAR2 (15 CHAR) NOT NULL,
ASOFDATE DATE NOT NULL,
SCHED_ID VARCHAR2 (8 CHAR) NOT NULL
)
;
CREATE UNIQUE INDEX EMP_SHIFT on EMP_SHIFT (EMPID, ASOFDATE, SCHED_ID)
;
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1980 ', 1, 8);
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1980 ', 2, 0);
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1980 ', 3, 8);
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1980 ', 4, 0);
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1990 ', 1, 9);
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1990 ', 2, 0);
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1990 ', 3, 9);
INSERT INTO SCHED_DATA VALUES ('SCHED_4D', 1 JANUARY 1990 ', 4, 0);
INSERT INTO SCHED_DATA VALUES ('SCHED_3D', 1 JANUARY 1990 ', 1, 8);
INSERT INTO SCHED_DATA VALUES ('SCHED_3D', 1 JANUARY 1990 ', 2, 4);
INSERT INTO SCHED_DATA VALUES ('SCHED_3D', 1 JANUARY 1990 ', 3, 0);
INSERT INTO EMP_SHIFT VALUES ('001', 20 DECEMBER 1989', 'SCHED_4D');
INSERT INTO EMP_SHIFT VALUES ('001', 1 JANUARY 1990', 'SCHED_4D');
INSERT INTO EMP_SHIFT VALUES ('001', 3 JANUARY 1990', 'SCHED_3D');
In view of the above, I need to write a select statement receives 2 dates (: of and: to) and for all employees of EMP_SHIFT returns one row for each day and the hours for that day.
Thus, the data above with one and from 21 December 1989 ': 5 January 1990 ' should return
EMPID, DATE, SCHED_HOURS
001, 21 - DEC, 0
001, 22 - DEC 8
001, 23 - DEC, 0
001, 24 - DEC 8
001, 25 - DEC, 0
001, 26 - DEC 8
001, 27 - DEC, 0
001, 28 - DEC 8
001, 29 - DEC, 0
001, 30 - DEC 8
001, 31 - DEC, 0
001, 01 - JAN 9
001, 02 - JAN, 0
001, 03 - JAN 8
001, 04 - JAN 4
001, 05 - JAN, 0
The employee began thir mission to sched_4d the 20 - DEC, then it would be SHIFT_ID 1. DEC 21 - Therefore SHIFT ID 2, which is 0 hours. Cycle until the next event which is 01 - JAN, when they are assigned to the new sched_4d who work 9 hours on day 1. 03 - JAN they pass to the new cycle and go to the 8:4:0 rotation.
I can see how I could
SELECT EMPID, DAY_OF_INTEREST, SCHED_ID
EMP_SHIFT a, (SELECT 1 January 1979 ' + rownum 'DAY_OF_INTEREST' from dual connect by level < = 10000)
WHERE A.ASOFDATE = (SELECT MAX (A1. ASOFDATE) OF A1 EMP_SHIFT WHERE A1. EMPID = A.EMPID AND A1. ASOFDATE < = DAY_OF_INTEREST)
AND DAY_OF_INTEREST BETWEEN: FROM_DT AND: TO_DT
And I guess I need to use some kind of MOD ((DAY_OF_INTEREST - EMP_SHIFT. ASOFDATE), (#number of days of shift)) which shift_id applies to a given Day_of_interest
But I'm struggling to do this in a way that could evolve to more than one employee,
The analytical functions achieve neatly?
Hello
There are several analytical functions that might help here. Two tables include only; departure dates we need to know the end dates of both employee assignments regarding schedules. I used the analytical functions MIN and LEAD to get these in the query below. In addition, the following query needs to know how many days is in each Annex. I used the analytical COUNT function for that.
WITH params AS
(
SELECT TO_DATE (December 21, 1989 ","DD_MON-YYYY"") AS start_date
, TO_DATE (5 January 1990 ', 'DD_MON-YYYY') AS end_date
OF the double
)
all_dates AS
(
SELECT the LEVEL - 1 AS a_date + start_date
OF params
CONNECT BY LEVEL<= (end_date="" +="" 1)="" -="">=>
)
sched_data_plus AS
(
SELECT sched_id, asofdate, shift_id, sched_hrs
NVL (MIN (asofdate) over (PARTITION BY sched_id
ORDER BY asofdate
RANGING FROM 1 TO MORE
AND UNBOUNDED FOLLOWING
) - 1
, TO_DATE (31-DEC-9999', 'DD-MON-YYYY')
) AS uptodate
, COUNT (*) OVER (PARTITION BY sched_id
asofdate
) AS days_in_sched
OF sched_data
)
emp_shift_plus AS
(
SELECT empid, asofdate, sched_id
NVL (in ADVANCE (asofdate) OVER (PARTITION BY empid
ORDER BY asofdate
) - 1
, TO_DATE (31-DEC-9999', 'DD-MON-YYYY')
) AS uptodate
Of emp_shift
)
SELECT e.empid
d.a_date
s.sched_hrs
Of all_dates d
JOIN the s sched_data_plus WE d.a_date BETWEEN s.asofdate
AND s.uptodate
JOIN e-emp_shift_plus WE d.a_date BETWEEN e.asofdate
AND e.uptodate
AND e.sched_id = s.sched_id
AND MOD (d.a_date - e.asofdate)
s.days_in_sched
) + 1 = s.shift_id
ORDER BY e.empid
d.a_date
;
This request is started by getting daily interest, that is, every day between the given - start and end dates. (When you said "random date", I assume you meant 'a date', data which may not involve any random element.)
Once we have a list of all the dates of interest, to get the results you want is just a matter of inner join to get the schedules were in effect on these dates, and which employees were assigned to these annexes to these dates.
If you are worried about having more than 1 employee, maybe you should post the sample data that has more than 1 employee.
How do you manage the endings of the employee? For example, what happens if the employee 001 had left on January 4, 1990? I guess that you would like the output for this employee stop January 4, rather than continue to the end of the period that interests us.
If you have dates of termination in an employee table not shown here, then you can use this date of termination instead of December 31, 9999 as the end date by default of the assignments. If you have a special schedule for endings (or leave, by the way) you'll probably want to include a WHERE clause in the main query does not display dates after the employee left (or when the employee was on leave).
-
How to find the redo generated by each SQL statement?
Database version is 10.2.0.4. OS is AIX.
We must again excessive generation during a specific time. We want to identify what a statement contributes to excessive recovery.
ADDM shows this as a first observation
Waiting on event "log file sync" during the execution of operations of COMMIT and ROLLBACK consumed at the time of the important data.
Is it possible to know which statement sql generates how many redo in bytes for a moment?
Thank you
DelphineIs it possible to know which statement sql generates how many redo in bytes for a moment?
It will not help you.
For example, you can see a lot of UPDATE, DELETE, INSERT from the apps statements. Then? What you do with them? If you can modify the application to eliminate the useless LMD - it would be great of course. But it is unlikely.When the DML statements also generate Redo, does not cause them too much expectations "log file sync", because the writer log buffer empty buffer as soon as it fulfills more than 30% after a certain time or on Commit / Rollback.
Waiting on event "log file sync" during the execution of operations of COMMIT and ROLLBACK consumed at the time of the important data.
Right. This is because the writer written newspaper here synchronous, reliable, he waits until the HDD writes data down and meets its written OK.
And hard drives are not the fastest things in the computer. They are mechanical - that's why.I would recommend:
1. place files redo log on quick drives used preference dedicated only to this end. If other I/O will often disturb these readers resulting securities heads change causing longer HDD expected.
2 consider using faster technology such as SAN or SSD. -
Use SQL statements to produce fragments xml as records
RHEL 6.2
11.2.0.4 (standard)
Example of XML Document
<?xml version="1.0" encoding="UTF-8"?> <MALSTransLog version="0.0.0.0"> <Trans> <TransId>1</TransId> <Blah>1</Blah></Trans> <Trans> <TransId>2</TransId> <Blah>1</Blah> </Trans> <Trans> <TransId>3</TransId> <Blah>1</Blah> </Trans> </MALSTransLog>
I'm trying out all the child nodes of "Trans" at MALSTranslog.
Was looking for select data such as:
transid trans_frag ------- ---------- 1 <Trans><TransId>1</TransId><Blah>1</Blah></Trans> 2 <Trans><TransId>2</TransId><Blah>1</Blah></Trans> 3 <Trans><TransId>3</TransId><Blah>1</Blah></Trans>
I tried the simple way to EXTRACT input, but it generates only one record containing all the child nodes.
SELECT EXTRACT (translog, '/MALSTransLog/Trans') trans_frag FROM translog WHERE file_name = '20150123213753Z.xml';
I forget a function that can pull the fragments as records?
See odie_63to post here: https://odieweblog.wordpress.com/2014/11/09/how-to-parse-sibling-repeating-groups-without-wrapper-element/
WITH translog AS ( SELECT XMLTYPE('
1 1 2 1 3 1 1 1 2 1 3 rows selected.3 1 HTH
M.
-
How to use SQL or another way to check if the assets have been post GL?
Hi all:
I wan to ask, how to use SQL statements or any other way to check iif assets have been post GL?
my environment is oracle 11.5.9
Concerning
Terryto create entries and transfer to GL
assets: -.
(1) (log N entries)-> standard
(2) complete the setting and submit.to check if the assets have been post GL
Journal:--
(1) magazines-> Enter
(2) in the form of research journals Source LOV, select 'Assets', then enter
(3) you will find all transferred assets (Addition or depreciation) magazines, and the status of the batch is (Unposted), then review and PostPublished by:! ALotfy September 2, 2010 08:54
-
How to restore primary after the managed failover to standby using sql
Please take note of measures to restore a back-end database after failing during the eve. The old standby mode is now the main role. Don't use only not the broker. You use SQL statements to restore the old primary back in custody of data.
Published by: 783527 on January 31, 2012 13:39Hello;
If you want a preview my quick test scores are here:
http://www.Visi.com/~mseberg/Data_Guard_Failover_Test_using_SQL.PDF
Best regards
mseberg
-
To change the way of afficherdans the data using SQL
I have data as follows:
Name age
Tom 24
Harry 45
Mona 30
I want to convert these data in the way below
Name1, name2 Age1 Age2 Name3 3
24 45 30 Mona Harry Tom
How can I do the same thing using SQL?Why not try to search this forum of 'PIVOT' to make this small change yourself?
SQL> set line 1000 SQL> WITH t AS (SELECT 101 empid,45 marks,8 rank FROM dual UNION ALL 2 SELECT 101 empid,62 marks,7 FROM dual UNION ALL 3 SELECT 101 empid,80 marks,2 FROM dual UNION ALL 4 SELECT 102 empid,67 marks,5 FROM dual UNION ALL 5 SELECT 102 empid,56 marks,6 FROM dual UNION ALL 6 SELECT 103 empid,87 marks,7 FROM dual UNION ALL 7 SELECT 103 empid,55 marks,9 FROM dual UNION ALL 8 SELECT 103 empid,60 marks,6 FROM dual UNION ALL 9 SELECT 103 empid,70 marks,3 FROM dual 10 ) 11 ---End of Sample Data 12 ---Now the original query. 13 SELECT empid, MAX(DECODE(rn1,1,marks)) Marks1,MAX(DECODE(rn1,1,rank)) Rank1 14 , MAX(DECODE(rn1,2,marks)) Marks2,MAX(DECODE(rn1,2,rank)) Rank2 15 , MAX(DECODE(rn1,3,marks)) Marks3,MAX(DECODE(rn1,3,rank)) Rank3 16 , MAX(DECODE(rn1,4,marks)) Marks4,MAX(DECODE(rn1,4,rank)) Rank4 17 FROM 18 (SELECT empid,marks,rank, 19 ROW_NUMBER() OVER(PARTITION BY empid ORDER BY marks) rn1 20 FROM t) 21 GROUP BY empid; EMPID MARKS1 RANK1 MARKS2 RANK2 MARKS3 RANK3 MARKS4 RANK4 ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 101 45 8 62 7 80 2 102 56 6 67 5 103 55 9 60 6 70 3 87 7 SQL>
-
I have trouble printing through my wifi network. How to remove a static ip address on my HP 8600, using mac 10.7.5 to work with wifi?
With the help of my NetGear N900 / CG4500BD modem/router with DHCP, there are different IP addresses of the printer, if the printer is connected is 192.168.0.13, when the printer use wifi IP is 192.168.0.20, and on the printer, it shows 192.168.1.142 I think is a static IP address, because it can cause the confussion.
I appreciate your help, thank you, the Job Dr.
Hello
Please go to system-> Network Preferences. Select the airport on the left, and then click Advanced in the bottom right. Switch to TCP/IP and select "using dhcp". Click ok, and then click on apply. After a few seconds, you should get an IP address from the router. -
I bought a new iPhone SE. My iCloud account still shows my old iPhone data use. How can I erase it from my ICloud account?
Do you mean that you see your old data use on the new iPhone?
Go to settings > cellular > [scroll down to] Reset Statistics
Otherwise, where exactly do you see this use?
-
How can I me thunderbird to show me which passwords he uses for my email accounts?
I use Ubuntu 14.04 and Thunderbird, and I need to find a way to get Thunderbird to show me what password he uses for each of my email accounts - and how I can change these passwords without deleting the old account and setting up new ones.
I have similar responses to similar problems, but these require I'll under "Tools" - "options" - and more far away, but I can't find any menu 'Options' anywhere in my version of Thunderbird. However, this shows me that this information must be able to access it somehow, also in my version.
Any help would be appreciated.
Yes available menus and commands in the Windows of Thunderbird version is different from the version of Linux, I don't know why.
I've got Xubuntu 14.04 so I guess that my version is the same as yours. See the Edit > preferences > Security > passwords > passwords saved. -
How can I get the taskbar to show when I want to use?
In many programs, the taskbar disappears from the bottom of the screen. Sometimes I need to use an icon that sits on the bar spots. How can I get the taskbar to show when I want to use an icon on this subject?
What are 'many programs' to make it happen? If you are using "full screen", you must leave this mode, usually by pressing F11 or ESC key.
Unless you are referring to a mode "full screen" programs...
- The taskbar should appear if you move the mouse to the bottom of the screen.
OR
- Right-click on an empty part of the taskbar, and then select Properties
Uncheck the box "auto-hide the taskbar."
Click OK
-
HOW TO MAKE A SLIDESHOW TO BE USED ON BLU - RAY, I MADE A SLIDESHOW IN LIGHTROOM, BUT I CAN ' FIND A WAY FOR BLU - RAY. JIMBUZZ1
Lightroom creates a DVD that can be played on other computers. This includes slideshows. If you want to be able to show your DVD into a Blu - ray or standard DVD player connected to the TV, then you must use a software that will create the DVD in the proper format. You might consider ProShow Gold, or Adobe Premiere Elements or similar programs. According to its capabilities and your TV, you might be able to simply display a regular data DVD images. My TV has an entry for a flash drive. I can load the images to a flash drive and view them directly. But if you want to show your slideshow on your TV, you need to author with appropriate software.
Maybe you are looking for
-
Facebook will not load on my laptop or desktop, but all other sites only
I restarted my computer - rebooted my router - redness DNS cache - I uninstalled mozilla and reinstalled - I tried IE and same problem - all other sites load except Facebook.
-
When I updated Firefox it adds a toolbar, which I don't. I understand how to get rid of, but I can't get rid of the giant HISTORY bar on the side left which takes 1.5 "of my screen space. I tried to use customize it to drag it off but it won't let me
-
Pretty much just the title of the topic. I'm sick of gingerbread, and I intend to return to Froyo (which can be done without rooting). However, has someone who already did know if the phone will update itself backwards or tirelessly upset me to updat
-
My mother the automatic updates on the pc and something has updated this morning when my mother was shut down the pc. I turned on the pc and it was a black screen and it looked like he was running through a few things. Then it stops on the followin
-
I bought my laptop Acer, 2 years there are with Vista installed, two months ago my laptop started having serious errors that forced me to re-install using my friends CD . when it came to the key, the key on my laptop was a little hard to make out, so