SQL diff result to_date and to_date
I have the SQL on 10.2.0.4 database with where clauseslect count (*) from abc_table where
"a.SRVC_FROM_DT between January 1, 2005" and on December 31, 2006.
When I came across it it gives me results like 400, when I RAM it gives me 2000 count of query below.
The second one is correct, what could be the reason to get resullts diff.
slect count (*) from abc_table where
a.SRVC_FROM_DT between to_date('01-JAN-2005','dd-mon-yyyy') and to_date ("31 December 2006","dd-mon-yyyy" ");
appricaite your help.
When you specify "between January 1, 2005" and the 31 December 2006 ' oracle reads in January 1, 2005 00:00:00 "format of an hour... so if you have something like 03:03:00 '(e.g..) January 1, 2005, stored in the column it will not play... then that between to_date('01-JAN-2005','dd-mon-yyyy') and to_date ("December 31, 2006 ',' dd-mon-yyyy '); changes January 1, 2005 03:03 ' on January 1, 2005 "only. It verifies that the date does not check the time factor.
Anand
Published by: Anand... Sep 17, 2008 01:08
Tags: Database
Similar Questions
-
Dear friends,
I'm under two different queries. one is to consolidate their value is another aggregate function, but the two total does not equal. You want to help me solve this strange issue.
-under query not displaying correct (comparatively less value)
Select abs (sum (c.dbt) - sum (c.crt))
of xx_coa_v1 c
where c.period_year = 2013
and c.segment4 between 100000 and 399999
and c.segment2 = '010'
and c.GROUP_LEVEL1 ("passive", "Equity")
-under query showing the correct value
Select abs(c.dbt-c.crt)
of xx_coa_v1 c
where c.period_year = 2013
and c.segment4 between 100000 and 399999
and c.segment2 = '010'
and c.GROUP_LEVEL1 ("passive", "Equity")
Concerning
Stressed
ABS (Sum (v) - Sum (x)) is not the same as sum (abs (v - x)).
That's the comparison that you did in my understanding, but you can't in any case, as indicated above.
-
Delete duplicate of PL/SQL command result values
Hi all
I am working on SQL Developer 4.1 and using sub PL/SQL command to retrieve the unique values of Batch_No with matching data:
Row_ SELECT TO_NUMBER (ROW_NUMBER () (IN Batch_No ORDER)),
Batch_No,
Record_Source,
Create_Date,
Submitter
Of
(SELECT DISTINCT Batch_No,
RecSource Record_Source,
Get_Date_From_Remedy (Create_Date) Create_Date,
Submitter
OF VOD_SEET_Invoices
WHERE (Batch_No <>"NA")
) batch
UNION
Row_ SELECT TO_NUMBER (ROW_NUMBER () (IN Batch_No ORDER)),
Batch_No,
Record_Source,
Create_Date,
Submitter
Of
(SELECT DISTINCT Batch_No,
'Penalties' Record_Source,
Get_Date_From_Remedy (Create_Date) Create_Date,
Submitter
OF VOD_SEET_Penalties
WHERE (Batch_No <>"NA")
) batch
The output of the above query has many duplicates in Batch_No, no idea how to rewrite the above query so that only unique values of Batch_No to the associated data are retrieved without duplicates?
Thanks in advance,
Kind regards
Mona Fathy
For example...
If your logic is that "Penalties" must have priority over the other record (assuming another in this scenario) of the first query, if there is a record of penalties, then by doing the following:
Select row_number() (order Batch_No) Row_
Batch_No
Record_Source
Create_Date
Author
de)
Select row_number() over (partition by order of batch_no to decode (record_source, 'Penalties', 0, 1)): the nurse
batch_no
record_source
create_date
author
de)
Select Batch_No
Record_Source
Create_Date
Author
to select (separate Batch_No
RecSource Record_Source
Get_Date_From_Remedy (Create_Date) Create_Date
Author
of VOD_SEET_Invoices
where (Batch_No <> 'NA')) batch
Union
Select Batch_No
Record_Source
Create_Date
Author
to select (separate Batch_No
"Penalties" Record_Source
Get_Date_From_Remedy (Create_Date) Create_Date
Author
of VOD_SEET_Penalties
where (Batch_No <> 'NA')) batch
)
)
where rn = 1
determines a row_number in each batch_no, ordering sanctions first duplicate records, and other records.
Then the outer query takes just the first records of each batch_no by applying the "where rn = 1" clause.
The outer query then applies his own row_number compared to results sorted by batch_no.
-
Hey everybody
I have a requirement where I need to get result separated by commas to names because there are many relationships that is, for each protocol, there are mutiple people linked to it, and I created the PL/SQL function for this and everything was going well and when he is in the production of several cursors have been opened due to the logic and leading to CARS more and for that we have summer manually clear cursors every weekend and I'm you're looking to create a view, materialized for this logic but I was unable to encode the logic by using Connect by clause
The result is like and I want the names separated by commas for each protocol
P06065 TESTER13 TESTER13
P02095 PATRICIA CARMELITANO
P02095 ANNE MUIR
P02095 ROBERT HARLOW
P02095 JANICE ALBERT
P02095 Jacqueline van Dalen
P02095 DR. GUENTER HENNIG.
P05209 Olga Xenaki
P05553 Birgit Limbach-Angele
P05553 Anja Dr. Schulz.
P05553 CHRISTA HAGENBUCHER
Here's the function I wrote, I need to get the same logic through the SQL statement... Thanks for your help
cursor c_GSCR is
Select T565804. FST_NAME | » '|| T565804. LAST_NAME
Of
S_PT_POS_HST_LS T544105 / * S_PT_POS_HST_LS_Protocol_Team * /,.
S_CONTACT T565804 / * S_CONTACT_Protocol_Team * /,.
S_CL_PTCL_LS T541903 / * S_CL_PTCL_LS_Protocol * /.
where (T541903. ROW_ID = T544105. CL_PTCL_ID and
T544105. POSTN_ID = T565804. PR_HELD_POSTN_ID and
T544105. ROLE_CD = 'Lead project manager' AND
T541903. ROW_ID = v_PTCL_ID and
T541903. PAR_PTCL_ID is set to null, and T544105. END_DT is null);
BEGIN
l_row_num: = 0;
l_role: = ";
l_role_list: = ";
v_PTCL_ID: = PTCL_ID;
C_GSCR OPEN;
If C_GSCR % isopen THEN
LOOP
FETCH C_GSCR INTO l_role;
When the output C_GSCR % notfound;
IF l_role_list IS NULL THEN
l_role_list: = l_role;
ON THE OTHER
l_role_list: = l_role_list | ',' | l_role;
END IF;
END LOOP;
CLOSE C_GSCR;
end if;
~ SrixHello
You can try something like this:
select loan_code, rtrim(xmlagg(xmlelement(e,loan_tran_code||',').extract('//text()')),',') as loan_tran_codes from st_lo_trans where st_code = 24 group by loan_code
-
GROUP BY clause diff in Sybase and Oracle
Hello
I am migrating from Sybase to Oracle code and came across a strange problem which is widely known to others :)
In Sybase, you can use columns or calculations in SELECTION expressions that do not appear
in the GROUP BY clause from the query. As
SELECT order.custid, customer.name, MAX (payments)
-> IN the order, customer
-> WHERE order.custid = customer.custid
-> GROUP BY order.custid;
works fine but for SQL, we must add customer.name to the customer of the GROUP BY clause.
In the same spirit, here is my SQL query
INSERT INTO GTT_CTRT_recalc_proc
(id_fin_rec,
id_imnt,
id_instr_opn,
dt_instr_opn,
dt_opn,
dt_cls_loanet,
dt_prcss,
am_invst)
SELECT t1.id_fin_rec,
T1.id_imnt,
T1.id_instr_opn,
T1.dt_instr_opn,
T1.dt_opn,
NVL (t1.dt_cls_loanet, l_dt_to),
T1.dt_prcss,
Sum (T2.am_invst) + (0.123 * (1 - abs (sign (0 - SUM (t2.am_invst)))))
OF GTT_CTRT_TEMP_recalc_process t1, GTT_CTRT_TEMP_recalc_process t2
WHERE t2.id < = t1.id
AND t2.id_imnt = t1.id_imnt
AND t2.id_instr_opn = t1.id_instr_opn
AND t2.dt_instr_opn = t1.dt_instr_opn
T1.id_imnt GROUP,
T1.id_instr_opn,
T1.dt_instr_opn,
T1.dt_opn,
T1.dt_cls_loanet,
T1.dt_prcss;
Has no t1.id_fin_rec in GROUP BY it fails in SQL.
I know that if I add this column in GROUP BY, it will work fine, but told me to keep the feature because it is as the result before and after the addition of the column is different, of course.
If please guide me what we can do in this situation and should work around that?
Thank you
AashishUse the PARTITION MORE rtaher than GROUP BY
INSERT INTO GTT_CTRT_recalc_proc (id_fin_rec, id_imnt, id_instr_opn, dt_instr_opn, dt_opn, dt_cls_loanet, dt_prcss, am_invst) SELECT t1.id_fin_rec, t1.id_imnt, t1.id_instr_opn, t1.dt_instr_opn, t1.dt_opn, NVL(t1.dt_cls_loanet, l_dt_to), t1.dt_prcss, SUM(t2.am_invst) OVER(PARTITION BY t1.id_imnt, t1.id_instr_opn, t1.dt_instr_opn, t1.dt_opn, t1.dt_cls_loanet, t1.dt_prcss) + (0.123 * (1 - ABS(SIGN( 0 - SUM(t2.am_invst) OVER(PARTITION BY t1.id_imnt, t1.id_instr_opn, t1.dt_instr_opn, t1.dt_opn, t1.dt_cls_loanet, t1.dt_prcss))))) FROM GTT_CTRT_TEMP_recalc_process t1, GTT_CTRT_TEMP_recalc_process t2 WHERE t2.ID <= t1.ID AND t2.id_imnt = t1.id_imnt AND t2.id_instr_opn = t1.id_instr_opn AND t2.dt_instr_opn = t1.dt_instr_opn
-
Share the expression in step.result.numeric and locals.variable
Hello together,
I'm new in the world of TestStand and I have a simple question.
How can I share the output of a step between the expression step.numeric.result (NumericLimitTest) and a variable 'local '? I need the output of a time step value for the comparison of the limit and once to give to the next step.
Thank you
Dusan
-
More than 1 SQL query with checkbox and error invalid number report
Hi all
I have two SQL query reports that each has an apex_item.checkbox and two processes for each report. A report/process works very well. It gives me an error of invalid number.
In addition, another query SQL (editable report) gives me the following error when using the Multi line process, delete.
ORA-06502: PL/SQL: digital or value error: character number conversion
error ORA-06502: PL/SQL: digital or value error: character number conversion
errorOk When I got a report from SQL query (with box and a process) and the query SQL (editable report) everything worked. It stopped working when I added another SQL query report (with box and a process).
A SQL query has the following in my query: apex_item.checkbox(3,email_id,'UNCHECKED') ""
The other SQL query has the following: apex_item.checkbox(2,b.file_id,'UNCHECKED') ""
Any help will be greatly appreciated,
Sylvia
Hi Reema,
I've recreated the region and now it works!
Thank you for this, looking at
Sylvia
-
I installed the SQL 4.0 developer and repository installation was a success. But the tools-> Data Miner-> Make visible option is not enabled. Also when I double click on the data minor user login I get the message workflow repository data need to be stored as xml binary on databases of version 11.2.0.4 or higher. You want to migrate your data from worklfow binary storage? WARNING: All sessions with the ODMRUSER role will be disconnected. Client version: 12.2.0.17.29 Version: 12.1.0.1.0 the database repository Version: 12.1.0.2.1. I don't have an older repository. Please help me solve this problem.
Try to create a data minor user account (for example DMUSER) using the script createuser.sql in the
\dataminer\scripts directory. Use this user account to connect instead of the anonymous account. Thank you.
-
SRM + SQL + 3rd party replication and suspend the DB
Gentlemen
What can the SRM to ensure customers a SQL VM running on (and replicated by) 3rd party storage is applied consistently? The HP SRA has code that can invoke the suspension in the virtual machine? Or is there some kind of way scripted as part of SRM, that a quiesce DB in the virtual machine can be triggered in tandem with or just as a LUN replication occurs?
I know that HP is responsible for the ASR - but in these situations, we sometimes get caught between vendors. Looking for experience "How have any other mission critical SQL resources protected using 3PAR and SRM".
In other words:
We are looking for assistance with a DR implementation for a specific application of SQL. The app is on virtual machines running on 3PAR storage. We bought all the necessary "3PAR suite application licenses" and then also have VMware SRM.
We are more concerned than LUNS replicated DR on-site production (LUN will be virtual computers hosting SQL data storage I assume) will be fully SQL-compliant (i.e. better than crash-consistent), during replication.
We have some experience with 3PAR replications - but to my knowledge have not yet worked with the application suites.
Question - anyone can describe what role (if any) suites of applications 3PAR can have in correctly the suspension SQL running on a virtual machine that is on a LUN 3PAR? I don't know we can do this medium - seems that we will have to use RDM (or vVOls if they are compatible SRM) be properly suspended the DB. Is there a HP storage agent that can run on a VM SQL in order to coordinate with the table when the underlying LUN snapshots are performed?
You are right. Consistency in the application will have to be managed at the level of the array. Some providers of table (I know NetApp specifically) offer the ability to place an agent on the VMS and this agent to use the table to ensure uniformity in the application, I'm not sure of HP.
Another option that you might look at is vSphere replication. VR offers quiecing VSS (with JEREMIAH) in native mode.
If you are looking for a specific response to the use of replication 3PAR application suites I suggest you post to a forum of HP. vVOLs are not yet compatible with SRM and I do not see how RDM you will get what you are looking for.
Finally, how you deal with your post, I would say that you do not assume that only men participate in this forum.
-
Hi all
We are planing to install ESXi host where are hosted with our SQL 2008 R2 SP1 machines, version 6. Do you know if this upgrade is supported by Microsoft?
I mean, we have a problem after the upgrade? Application errors, incompatibility, etc...
Thank you
Chris
The virtual machine will not know that anything has been updated, but if you update the hardware version of the virtual machine update then there will be an operating system level changes. VMTools update necessary and the material presented.
I did some updates from 5.5 to 6, including sites where SQL server is running and have not had any problems. Just make sure you test first and do you homework with the HCL, etc..
-
Diff between dialog and Document Windows?
Hi all
What is the Diff between dialogue and Document Windows?
Thank you
Window Style antonyms:
MDI applications display a default parent, called the application window window. All other application windows are document windows or dialog windows.
Document windows remain as part of the application window. If the user resizes the application window so that it is smaller than a document window, the document window is cropped. An operator can enlarge a document window occupies the whole workspace of the application window.
Dialog windows are floating, and the operator can move outside the window of the application if they have been defined as mobile. They cannot be minimized, maximized, or resized by the operator.
Valid only for a secondary window. (A root window is a document window.)
-
SQL of VMware servers and balloon memory
Hello
Who wish to know the best practices of VMware and SQL with regard to the ball of the memory.
We have a few small SQL servers with 1CPU and 1 GB of ram, a single small database running. But we find ball memory is to come in the virtual machine of VMware and stay inflated for hours even days performance problems, causing for these virtual machines.
Should I reserve the memory that this virtual machine has, or should I disable the balloon on this prompt. Or maybe increase his "shares" to that of the other guests on the same host.
Any information on this topic would be useful, thank you in advance
This article shows you what to look for in esxtop to help solve the problem, http://www.yellow-bricks.com/2010/06/10/is-this-vm-actively-swapping-helping-heiner_hardt/. At one point, you had a certain type of constraint to inflate. I still think that the booking for SQL server is the way to go.
If you have found this device or any other useful post please consider the use of buttons useful/correct to award points
Twitter: http://twitter.com/mittim12
-
How to get the sql query result?
Hello
Currently I use LV2012 to connect to an Oracle database server. After the Oracle Express and Oracle ODBC driver facilities/settings made.
I managed to use the SQL command to query the data through my command prompt window.
Now the problem is, how to do the same task in Labview using database connectivity tools?
I have build a VI to query as being attached, but I have no idea of what range to use to get the result of the query.
Please help me ~ ~
Here is a piece of code that I use to test the SQL commands, you can use the part that retrieves the results of sql.
It is also possible to get the rear column headers, but it's for the next lesson!
;-)
-
SQL stored procedure input and output parameters
Hello Gang,
My dead end trying to call a stored procedure in SQL Server 2008 with the LV database tool.
for purposes of experimentation, I've created a small procedure with an input parameter that returns an integer as return value. It works describing a query, but all attempts at LV produce an error-2147217900 when executing query VI. I did find examples of that.
Sending a bunch of parameters to a stored procedure and checking the value of return seems to be pretty common stuff.
I'll appreciate any help.
Thank you
Roger
Hi Roger,
There are a few prerequisites which I will list below. If you have not checked these things, so don't hesitate, as your hiccups can be there.
Prerequisites:
- Ensure that you can read from a table in the database to verify that you can access the database (user permissions) and ensure that your login details are correct. Among other things, make sure that the. DSN switches to the correct database. (See the simple example below, SQL Select.vi)
- Make sure that your user (if you use SQL authentication) has permissions to run the STORED procedure by running the procedure in SQL Server Management Studio (you seem to have already done this)
Example by calling a procedure without parameters (attached as SPROC_No_Parameters.vi):
Example by calling a procedure with parameters (attached as SPROC_Parameters.vi):
An article on the execution of stored procedures is here:
http://digital.NI.com/public.nsf/allkb/07FD130746083E0686257300006326C4
Don't forget to download the example VI since it includes the cases where you want an output parameter of the procedure rather than a table.
I tested these against two very simple SPROCs and it worked fine (on SQL Server 2005, but 2008 should be the same). Stored procedures have been:
CREATE PROCEDURE [dbo]. [GetContacts]
AS
BEGIN
-SET NOCOUNT ON added to avoid additional results sets from
-interfering with SELECT statements.
SET NOCOUNT ON;-Controls insert for procedure here
SELECT * FROM Contacts
ENDand
CREATE PROCEDURE [dbo]. [MultiplyAges]
@param1 INT = 1
AS
BEGIN
-SET NOCOUNT ON added to avoid additional results sets from
-interfering with SELECT statements.
SET NOCOUNT ON;-Controls insert for procedure here
SELECT (age * @param1) OF Contacts
ENDI would like to know if these examples work for you or if you have any other questions. Don't forget to go through this KB article and articles related to it, they should cover other situations.
Matt
- Ensure that you can read from a table in the database to verify that you can access the database (user permissions) and ensure that your login details are correct. Among other things, make sure that the. DSN switches to the correct database. (See the simple example below, SQL Select.vi)
-
Hello
Here's my data in the table for itm_id = 1000
ITM_ID ADD_ATR DEL_ATR 1000 a: b:c:d 1000 d 1000 d 1000 e:f:g 1000 e:f:g My required return is (a: b:c:d) d = a: b: c + d = a: = a +(e:f:g) b:c:d: b:c:d:e:f:g-(e:f:g) = a: b: c; d
Output ITM_ID
1000A: b:c:d
can we get the output using the sql query above?
I had tried with union but could not able to get the required result.
Please let me know if there is no possible solution
Thank you
David
I have the impression that you are looking to treat each character in 'RTA' as an individual item and then add or delete depending on whether they are an ADD_ATR or DEL_ATR.
So something like...
SQL > ed
A written file afiedt.buf1 with t as (select 1000 as itm_id, ' a: b/c: some like add_atr, null as del_atr of all the double union)
2 select 1000, null, would be "union double all the"
3 select 1000, 'd', null of union double all the
4 select 1000, 'e:f:g', null of union double all the
5 select 1000, null, "e:f:g" of all the double union
6 select 1234, null, "x: y: z" of all the double union
7 select 1234, 'u: v: w', null of union double all the
8 select 1234, null, 'u' of all the double union
9 select 1234, "x: y", null of union double all the
10. Select 1234, "x: z", null of union double all the
11. Select 1234, 'p', the double null
12 )
13-
14. end of test data
15-
16. Select itm_id
17, cast (listagg(atr,':') within the Group (order by atr) as varchar2 (40)) output
18 of)
19 select itm_id
20, atr
21, sum (add_del)
22 of)
23 select itm_id
24, coalesce(add_atr,del_atr) as full_atr
25, decode (add_atr, null,-1, 1) as add_del
26, regexp_substr (coalesce(add_atr,del_atr),'[^:] +', 1, level) RTA
27, flat surface that l
28 t
29 to connect by level<= (length(coalesce(add_atr,del_atr)="">=>
30 and itm_id = prior itm_id
31 and coalesce(add_atr,del_atr) = prior coalesce(add_atr,del_atr)
sys_guid() 32 and prior is not null
33 )
34 group by itm_id, atr
35 having sum (add_del) > 0
36 )
37 * group by itm_id
SQL > /.ITM_ID OUTPUT
---------- ----------------------------------------
1000A: b:c:d
1234 p:v:w:xthat just shows how stupidly data is as it should be divided every thing in the different elements so that you can then group to determine how many of each, you have (and whether to add or subtract) and then re - combine results again in a combined string.
Maybe you are looking for
-
Result of global search of Thunderbird in window/tab black
Version of Thunderbird on Ubuntu 15.04 31.6.0Graphics card: 0.4 on AMD RV635 Gallium Performing a global search (Ctrl-K) opens new tab which is black and is not visible.I tried to change change the following without success:layers. Acceleration.disab
-
15-BA079DX HP: HP 15-BA079DX
This laptop has wifi or any whitelist whitelist?
-
Out Look express I compacted my messages. Messages from 17/01/2012 to 01/04/2012 are not in my Inbox and I didn't remove them where are?
-
DELETION OF PERSONAL INFORMATION
I need to have my old printer Photosmart HP 6510. How can I delete all the personal information of the printer?
-
ML6000 not detected in Windows Server 2012
Hello Our ML6000 is not detected by a new Windows Server 2012 host. It is not found in the Device Manager. However, the 3 SAS LTO 5 inside drives are detected properly. It used to be connected only to a Windows 2003 R2 server and is detected without