Need a sql query to get several dates in rows
Hi all
I need a query to get the dates of the last 7 days and each dates must be in a line...
but select sysdate double... gives a line...
Output of expexcted
Dates:
October 1, 2013
30 sep-2013
29 sep-2013
28 sep-2013
27 sep-2013
26 sep-2013
Try:
SQL > SELECT sysdate-7 + LEVEL FROM DUAL
2. CONNECT BY LEVEL<=>=>
3 * ORDER BY 1 DESC
SQL > /.
SYSDATE-LEVEL 7 +.
-----------------------------
October 1, 2013 13:04:52
30 - Sep - 2013 13:04:52
29 - Sep - 2013 13:04:52
28 - Sep - 2013 13:04:52
27 - Sep - 2013 13:04:52
26 - Sep - 2013 13:04:52
25 - Sep - 2013 13:04:52
7 selected lines.
Tags: Database
Similar Questions
-
Need to SQL query to filter records by limited rows and certain condition
Hello guru (s).
I need a SQL query for help.
For an example table t1 as below, I want to find the maximum of 5 larger, but there should be no more than 2 name of the same position. The "BOLD" is the response of desire.
Name Position size
N1 P1 5
N2 P2 50
N3 P3 500
N4 P1 6
N5 P2 60
N6 P3 600
N7 P1 7
N8 P2 70
N9 P3 700
Thank you.not tested!
select name,position,size, from (select name,position,size, row_number() over (order by size desc) a_count from (select name,position,size, row_number() over (partition by position order by size desc) a_count from your_table ) where a_count <= 2 ) where a_count <= 5
Concerning
Etbin
-
Need for SQL query to get the result.
Region
Month Trx type Summary of the resolution AMERICAS -13 may Adjustments Fix EMEA -13 may Adjustments Incorrect AMERICAS -13 may Credit memo Incorrect EMEA -13 may Invoice Fix AMERICAS -13 may Credit memo Fix OFD -13 may Adjustments Fix AMERICAS -13 may Invoice Incorrect DVL -13 may Adjustments Fix DVL -13 may Adjustments Fix OFD -13 may Adjustments Fix Above my Table and here is the result required. Similarly for other regions as well. Can someone help me with the SQL query?
Region Summary of the resolution Setting Credit memo Invoice Total general AMERICAS Fix 1 1 2 Incorrect 0 1 1 2 Like this?
SQL > select * from transaction_audit;
MTH TRX_TYPE REGION BOARD
-------- ------ ----------- ---------
AMERICAS-13 may SETTINGS CORRECT
EMEA-13 may INCORRECT ADJUSTMENT
AMERICAS-13 may CREDIT MEMO INCORRECT
EMEA-13 may INVOICE CORRECT
AMERICAS-13 may CREDIT MEMO CORRECT
OFD-13 may SETTINGS CORRECT
AMERICAS-13 may INVOICE INCORRECTE
LAD-13 may SETTINGS CORRECT
LAD-13 may SETTINGS CORRECT
OFD-13 may SETTINGS CORRECT10 selected lines.
SQL > select region
2, resolution_summary
3, count (decode (trx_type, "ADJUSTMENTS", trx_type)) adjustments
4, County (decode (trx_type, 'HAVING', trx_type)) credit_memo
5, County (decode (trx_type, "BILL", trx_type)) Bill
transaction_audit 6
Group 7
8 by region
9, resolution_summary
10 Decree
11 by region
12, resolution_summary
13.REGION TAKE ADJUSTMENTS CREDIT_MEMO INVOICE
-------- --------- ----------- ----------- ----------
CORRECT THE AMERICAS 1 1 0
0 1 1 INCORRECT AMERICAS
EMEA CORRECT 0 0 1
INCORRECT EMEA 1 0 0
DAL ADDRESS 2 0 0
OFD CORRECT 2 0 06 selected lines.
SQL >
-
SQL query to get the dates between two dates
Hello
We have a chart with start date and end date... Now I need to get all the dates between the start date and end date...
Table looks to below...
Create the table date_table (start_date, end_date date);
The table data will be as below:
start_date end_date
January 1, 2013 January 4, 2013
February 1, 2013 February 3, 2013
............... .................
............... ..................
............... .................
May 1, 2013 may 3, 2013
I want a result like below...
holiday_dates
January 1, 2013
January 2, 2013
January 3, 2013
January 4, 2013
February 1, 2013
February 2, 2013
February 3, 2013
.................
.................
.................
.................
May 1, 2013
May 2, 2013
May 3, 2013
Can anyone help... ?
Ramesh9158 wrote:
Hello
Your query will not work for our case...
First... We do not know the number of rows in the table... If we cannot use the union...
Second... hard coding of dates... but we do not know what could be that goes back in the table... it could be no matter what it takes not only as appearing to the interpreter...
Hey riri.
My code will work everywhere I use with with union all statement to create the example data.
Try the query:
-The main query
Select d1 + row_number() over (partition by iden) - stopped by iden holiday 1
Of
connect by level<= d2="" -="" d1="" +="">=>
and prior iden iden =
and prior sys_guid() is not null
----
Ramin Hashimzade
-
Need for the sql query to have several columns in a single coulumn
Hi all
I need create the query to have several columns in a single column with several lines.
Select a.customer_trx_id, a.previous_customer_trx_id
of ra_customer_trx_all one
where a.customer_trx_id =: customer_trx_id
Here, a.customer_trx_id and a.previous_customer_trx_id are in two columns. I need to put them in a single column.
Say: the foregoing is output
--------------------------------------------------------------------------------
a.customer_trx_id a.previous_customer_trx_id
--------------------------------------------------------------------------------
123456 87654
--------------------------------------------------------------------------------
Need for a single column
As
--------------------------------------------------------------------------------
123456
87654
--------------------------------------------------------------------------------
Please do the needful. Please note that it is not the UNION.
Thank you
AbdulHello
You want a way to confirm that what looks like two rows is really a line?
Here are three ways:
(1) count the lines:
WITH my_original_querry AS ( select a.customer_trx_id || CHR(13) || a.previous_customer_trx_id as id from ra_customer_trx_all a where a.customer_trx_id = 274881 ) SELECT COUNT (*) FROM my_original_query;
(2) in SQL * Plus, have SQL * more count them for you:
SET FEEDBACK 1 select a.customer_trx_id || CHR(13) || a.previous_customer_trx_id as id from ra_customer_trx_all a where a.customer_trx_id = 274881;
(3) implicitly count them with the ROWNUM Pseudo-column
select a.customer_trx_id || CHR(13) || a.previous_customer_trx_id as id , ROWNUM from ra_customer_trx_all a where a.customer_trx_id = 274881;
-
SQL query to get the NULL records after the last matching flag
I have a xx1 table with id and flag columns. So I want the data in this table, after the last flag matched. I want that data to id 7 in the rooms. Even if the id 2,3,5 are null flag 'Y' was at 6. ID so I need a query to get the data of the xx1 table after the last correspondence flag (from 7 to 9 id).
SQL > create table xx1
2 (identification number,
3 flag varchar2 (10));
Table created.
SQL > insert into xx1 values (1, 'Y');
1 line of creation.
SQL > insert into values xx1 (2, null);
1 line of creation.
SQL > insert into values xx1 (3, null);
1 line of creation.
SQL > insert into xx1 values (4, 'Y');
1 line of creation.
SQL > insert into values xx1 (5, null);
1 line of creation.
SQL > insert into xx1 values (6, 'Y');
1 line of creation.
SQL > insert into values xx1 (7, null);
1 line of creation.
SQL > insert into values xx1 (8, null);
1 line of creation.
SQL > insert into values xx1 (9, null);
1 line of creation.
SQL > select * from xx1.
FLAG OF THE ID
---------- ----------
1. IS
2
3
4. IS
5
6. IS
7
8
9
9 selected lines.
SQL >
Hello
user11164339 wrote:
Hi Frank - when I run the query, I don't see the results data.
I get
FLAG OF THE ID
----- ----------
7
8
9
What you do differently?
-
How to write a simple select query to get the data of the table as an XML.
How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select queryselect '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' from temp_table where id_num BETWEEN 1 AND 10;
without using XMLGEN, XMLQUERY or any other packages built and function?I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.
What is wrong with him?
At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:SQL> create or replace function my_url_escape (url in varchar2) 2 return varchar2 3 deterministic 4 is 5 begin 6 return utl_url.escape(url, false, 'AL32UTF8'); 7 end; 8 / Function created SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual; MY_URL_ESCAPE('HTTP://SOME.URI -------------------------------------------------------------------------------- http://some.uri.com/param?lang=fr&text=contr%C3%B4le
-
Hi all
Sorry I can't speak English very well
=======================
I have a table that contains two columns
table name: total_sal
column name: hire_date
column name: salary
table syntax
create table total_sal (hire_date date
number (6.2)) of salary;
_________________________________________
Example of data in table format
hire_date | salary
01/01/2011 | 1000
01/02/2011 | 2000
01/05/2011 | 500
01/09/2011 | 400
I NEED a SQL QUERY to display the table, as in this example
OF | TO|||||||||||| TOTALSALAY
01/01/2011 | 01/02/2011 | 3000
07/05/2011 | 01/09/2011 | 900
|||||||||||||||||||||||||||||||||| 3900/* Formatted on 9/23/2011 10:14:40 AM (QP5 v5.149.1003.31008) */ WITH t AS (SELECT TO_DATE ('1/1/2011', 'mm/dd/yyyy') hire_date, 1000 salary FROM DUAL UNION SELECT TO_DATE ('2/1/2011', 'mm/dd/yyyy'), 2000 FROM DUAL UNION SELECT TO_DATE ('5/1/2011', 'mm/dd/yyyy'), 500 FROM DUAL UNION SELECT TO_DATE ('9/1/2011', 'mm/dd/yyyy'), 400 FROM DUAL) SELECT "From", "To", totalsalary FROM (SELECT hire_date "From", LEAD (hire_date) OVER (ORDER BY hire_date) "To", salary + LEAD (salary) OVER (ORDER BY hire_date) totalsalary, ROW_NUMBER () OVER (ORDER BY hire_date) rn FROM t) WHERE MOD (rn, 2) = 1 UNION ALL SELECT NULL, NULL, SUM (salary) FROM t
From To TOTALSALARY 1/1/2011 2/1/2011 3000 5/1/2011 9/1/2011 900 3900
-
SQL query to assign several concurrent programs to the concurrent Manager.
Hello
You have any script to assign a list of program contributing to separate concurrent managers. Currently, there are more than 100 programs need to be assigned to the manager.ut
We do front end, but it will take quite a long time to complete this task.
Could you please help me on this.
Thank you and best regards,
Simone.
Hi Simone,.
First of all I need a sql query to find out what custom programs are assigned to which Manager.
Please see:
How can I tell which concurrent Manager handled a simultaneous [ID 344011.1] application/program
Find all programs assigned to the specialization Manager rules? [271283.1 ID]
Second, I have to give these programs customized to different custom managers.
See if this helps:
https://forums.Oracle.com/thread/2343489
Thank you &
Best regards
-
SQL query to get the numbers from 0 to 99
How can we write a sql query to get values from 0 to 99... This should not come from any tableSELECT LEVEL - 1 FROM DUAL CONNECT BY LEVEL <= 100 /
SY.
-
SQL query to get the range of Date values
Hello
The database is Oracle11i.
I'm looking for a way to generate a list of the dates of a fixed date in the past (could be hardcoded) at the time of the day (sysdate).
In other words, if the fixed date is June 19, 2011, and assuming today ' today is June 24, 2011 the SQL must be able to generate the
Next: -.
June 19, 2011
June 20, 2011
June 21, 2011
June 22, 2011
June 23, 2011
June 24, 2011
And the constraint is that I can not make any change to the database in question. I can only shoot a (SELECT) SQL query. NO.
use time dimension type of approach (time dimension is not available here) and no procedure, etc. from PL/SQL. Is it possible?
Thank youJaimeen Shah wrote:
HelloThe database is Oracle11i.
I'm looking for a way to generate a list of the dates of a fixed date in the past (could be hardcoded) at the time of the day (sysdate).
In other words, if the fixed date is June 19, 2011, and assuming today ' today is June 24, 2011 the SQL must be able to generate the
Next: -.
June 19, 2011
June 20, 2011
June 21, 2011
June 22, 2011
June 23, 2011
June 24, 2011And the constraint is that I can not make any change to the database in question. I can only shoot a (SELECT) SQL query. NO.
use time dimension type of approach (time dimension is not available here) and no procedure, etc. from PL/SQL. Is it possible?
Thank you
SQL> def date_start = '13/11/2010' SQL> def date_end = '22/11/2010' SQL> with 2 data as ( 3 select to_date('&date_start', 'DD/MM/YYYY') date1, 4 to_date('&date_end', 'DD/MM/YYYY') date2 5 from dual 6 ) 7 select to_char(date1+level-1, 'DD/MM/YYYY') the_date 8 from data 9 connect by level <= date2-date1+1 10 / THE_DATE ---------- 13/11/2010 14/11/2010 15/11/2010 16/11/2010 17/11/2010 18/11/2010 19/11/2010 20/11/2010 21/11/2010 22/11/2010
-
SQL query to represent the data in the graph bar
Hello
JDev 11.1.1.5.0
We must create a dashboard to track the translation. We have created the ADF table with buttons 'Create', 'Update' and 'Delete' to manipulate the table.
Our DB table structure is
File_id (PK), File_Name, ToSpanish - ARE (YES/NO), beginning of the ToSpanish, ToChina(YES/No), ToChina-Date... etc.
Once the translated file required language then user must update the DB table using the button "Update".
So far, we have implemented the requirement above.
We need represent the status of the translation in the graph bar with the language as X access and file count get access Ex: Spanish-100 China - 200 files files
Please suggest the sql query to retrieve the necessary info from the DB table that can be represented in the graph bar. Also, it would be great, if you can provide a pointers to create a bar chart.
Thanks in advance,
MSR.
If you set your major increment and minor than 1, then you won't not show decimal points. You can try setting these 10 or 100 to reach your goal.
Subtype = "BAR_VERT_CLUST" >
-
Oracle PL SQL Question to get some data to oracle tables descrepancy
Version of database
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production
PL/SQL Release 9.2.0.8.0 - Production
CORE Production 9.2.0.8.0
AMT for HP - UX: 9.2.0.8.0 - Production Version
NLSRTL Version 9.2.0.8.0 - Production
created a few sample data
drop table tab1 purge;
create table tab1 (DEPT_ID COMP, qc_subtype_id char (4), EQUIP_CODE varchar2 (20), create_time date);
Insert into tab1 values(13,'1026','HEMORYA011',sysdate);
Insert into tab1 values(13,'1012','HEMORYA011',sysdate);
Insert into tab1 values(95,'1026','HEMORYA121',sysdate);
Insert into tab1 values(95,'1012','HEMORYA121',sysdate);
----------------------
Insert into tab1 values(13,'1026','HEMORYA014',sysdate);
Insert into tab1 values(13,'1012','HEMORYA005',sysdate);
Insert into tab1 values(13,'1012','HEMORYA013',sysdate);
Insert into tab1 values(95,'1012','HEMORYA013',sysdate);
Insert into tab1 values(95,'1012','HEMORYA148',sysdate);
commit;
I need to get a query to get the records of the gap
Dept HEMORYA014 13 lack 1012
HEMORYA005 dept 12 lack 1026
Dept HEMORYA013 13 lack 1026
The dept 95 lack 1026 HEMORYA013
The dept 95 lack 1026 HEMORYA148
I want to show the latter on the report
Thanks in advance.Thanks for posting a unit test.
I hope it will work for you, but maybe you will need to set the WHERE clause (add additional predicates).SQL> select equip_code 2 from ( select equip_code 3 , count(distinct qc_subtype_id) 4 from tab1 5 group by equip_code 6 having count(distinct qc_subtype_id)<2 7 ) 8 order by equip_code; EQUIP_CODE -------------------- HEMORYA005 HEMORYA013 HEMORYA014 HEMORYA148
-
IOM sql Query to get the status of the failed task
Hello world
We have an obligation as we need to get the status of a particular task (say Create User in OID - Completed\Rejected status resource) for the particular user. We are able to get the status of the provisioed of resources to the user but not the status of the special mission which is trigerred for the user.can someone put some light on it. We must have the SQL query to do this.
Thanks in advance.
Kind regards
MKNHello
Use this query to get the status of the task, also check the coomentsSELECT USR. USR_LOGIN, OSI. SCH_KEY, ANN. SCH_STATUS, STA. STA_BUCKET OF
OSI, CHS, STA, MIL, TOS, PKG, OUEDRAOGO, USR, OBJ, OST
WHERE OSI.MIL_KEY = MIL.MIL_KEY
AND ANN. SCH_KEY = OSI. SCH_KEY
AND STA. STA_STATUS = SCH. SCH_STATUS
AND TOS. PKG_KEY = PKG. PKG_KEY
AND MIL. TOS_KEY = TOS. TOS_KEY
AND OUÉDRAOGO. USR_KEY = USR. USR_KEY
AND OUÉDRAOGO. OST_KEY = OST. OST_KEY
AND OST. OBJ_KEY = OBJ. OBJ_KEY
AND OSI. ORC_KEY = OUEDRAOGO. ORC_KEY
AND OBJ. OBJ_NAME = "User AD".
AND OST. OST_STATUS = "Provisioning" - filter accordinglly
AND STA. STA_BUCKET = 'pending' - filter accordinglly
AND PKG. PKG_NAME = "AD User" - filter accordinglly
AND MIL.MIL_NAME = 'System' - filter accordinglly Validation
;
Thank you
Kuldeep -
Hello everyone,
How can I create a query having 2 date and 2 variable of the type:
Thanks in advancefrom 1 date 05/06/2004 to 2 date 15/06/2004 yes for 2 days no for 1 day that is, i wish get the date with yes for 2 days and not for 1 day, this is, that I want 05/06/2004 sabato 06/06/2004 domenica 08/06/2004 martedì 09/06/2004 mercoledi 11/06/2004 venerdi 12/06/2004 sabato 14/06/2004 lunedi 15/06/2004 martedi
Hello
The WHERE clause controls the lines will appear.
If your needs change, change the WHERE clause to reflect their.For example:
DEFINE from_date = "TO_DATE ('05/06/2004', 'DD/MM/YYYY')" DEFINE to_date = "TO_DATE ('15/06/2004', 'DD/MM/YYYY')" DEFINE yes_cnt = 3 DEFINE no_cnt = 2 SELECT &from_date + LEVEL - 1 AS dt FROM dual WHERE MOD ( LEVEL , &yes_cnt + &no_cnt ) BETWEEN 1 AND &yes_cnt CONNECT BY LEVEL <= 1 + &to_date - &from_date ORDER BY dt;
This will work as long as you want the first & yes_cnt lines to display (assuming that there are many) and the following lines & no_cnt don't step to display, and then another & yes_cnt lines to display and the other & no_cnt lines not to display and so on.
I guess & yes_cnt is a positive integer and that & no_cnt is a non-negative integer. (I.e. & no_cnt can be 0)
Maybe you are looking for
-
Synchronization is not restore my saved favorites
I just installed firefox on my computer reformatted. I've linked it with sync, but not my data transferred.Help, please.
-
my gmail is not loading properly
I'm logged into my gmail account the page opens but is a blank white screen my inbox should have appeared
-
Save the file text at different rates
Hi all I'm kinda new to LabView, so perhaps this question is trivial, but gives me a lot of pain. I want to permanently save a string given at two different rates; in the example provided these rates are every 500 ms and ms 50, in two different (one
-
Game problems__ resizing
My games to play in full screen, but now they all play small, how can I change their return in full screen
-
My computer is blinking, unable to do anything
My header bar is a thing of flashing roller kina (for lack of better wording). When it does that it will close a pull down when he flashes... won't let me open a window of game program (it minimizes the blink)... it will push my typing at the beginn