Count records in different tables with a condition
HelloI would like to ask for your help. I want to count the records from multiple tables at the same time. These tables have a common column with them with a date data type. The output I want is to see the records in the tables with a condition of the column_date < (specified date).
as of:
Select count (*) from (the_tables) where (column_date), (specific_date)
Your help would be much appreciated.
Hello
|| ' WHERE ITEMDATE <= 8/1/2008;';
With the Frank remark about the mistake, another good practice would be to use a connection variable:
script_sql := 'SELECT COUNT (*) FROM '
|| r_1.owner
|| '.'
|| r_1.table_name
|| ' WHERE ITEMDATE <= :1';
...
EXECUTE IMMEDIATE script_sql
INTO this_cnt
USING to_date('08/01/2008','DD/MM/YYYY');
Tags: Database
Similar Questions
-
How to read/select only the records from a table with non-English characters
Hello
I need to find all records in a table with non-English (mainly Chinese) characters in at least one of the varchar2 columns. Let me kow if someone knows a way by which it can be done using SQL/PLSQL.
Best regards
Imranselect * from your table where your_column != convert(your_column, 'UTF8', 'US7ASCII)
Replace UTF8 with your database character set
Published by: thtsang on October 15, 2009 03:53 - unequal sign change of! =
-
By comparing the number of different records of different tables of databases with Production DB
Hello
I updated 6 paintings of DEVEOPMENT and QA database production databases.
According to the request of the customer, I want to create a stored procedure to compare the number of tables with the number of Production DB records.
Could you please suggest me a better way to do this.
example: select count (*) in the emoployee@Devlopment_Database. -I want to check with select count (*) from employee@Procuction_Database
Select count (*) in the emoployee@QA_Database. -I want to check with select count (*) from employee@Procuction_Database
Thank you
Vincent
If so, your question is asking how to create a database link?
-
Count the number of records in all tables with a querry URGENT please...
I downloaded ORACLE 9I DATA DUMP in my computer. There are number of tables. I need to know the tables with records more of say 100 or on the go. Is it possible... If so kindly let me know.
Second, the database that I downloaded, I discovered that Audit_ trial was not activated by cooking
' select name, value of v$ parameter.
where name like '% verification' and it turned out to be false.
Can we assume that the database in the server as the audit_trial has been disabled...
Published by: user1287492 on October 21, 2009 09:07Hello
Place the table name with quotes. Maybe that's the problem.
Try this code
select table_name, to_number( extractvalue( xmltype( dbms_xmlgen.getxml('select count (*) c from "'||table_name||'"' )) ,'/ROWSET/ROW/C')) COUNT FROM USER_TABLES where iot_type IS NULL /
SS
-
Matching records between 2 tables with duplicate records
Hi all
I need help in what follows.
I have 2 tables Received_bills and Send_bills.
-------------------------------------------------------
-The DOF for Table SEND_BILLS
--------------------------------------------------------
CREATE TABLE SEND_BILLS
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE)
) ;
--------------------------------------------------------
-The DOF for Table RECEIVED_BILLS
--------------------------------------------------------
CREATE TABLE 'RECEIVED_BILLS '.
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE),
VARCHAR2 (5 BYTE) 'STATUS' ) ;
INSERTION of REM in RECEIVED_BILLS
TOGETHER TO DEFINE
Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
INSERTION of REM in SEND_BILLS
TOGETHER TO DEFINE
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.
Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results
the query I wrote is this:
SELECT SEND.*
REC received_bills, send_bills send
WHERE send.datum = rec.datum
AND send.payment = rec.payment
AND send.code = rec.code
AND 'rec.status =' SUCCESS
;
The query results give me this
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 The result of the correct application would be
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 The select statement that I need I want to use a loop to insert records in another table.
Can someone help me please?
Thanks in advance.
Best regards
Caroline
Hi, Caroline.
Caroline wrote:
Hi all
I need help in what follows.
I have 2 tables Received_bills and Send_bills.
-------------------------------------------------------
-The DOF for Table SEND_BILLS
--------------------------------------------------------
CREATE TABLE SEND_BILLS
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE)
) ;
--------------------------------------------------------
-The DOF for Table RECEIVED_BILLS
--------------------------------------------------------
CREATE TABLE 'RECEIVED_BILLS '.
(DATE OF "DATUM",
NUMBER OF "PAYMENT."
'CODE' VARCHAR2 (5 BYTE),
VARCHAR2 (5 BYTE) 'STATUS');
INSERTION of REM in RECEIVED_BILLS
TOGETHER TO DEFINE
Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');
Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');
INSERTION of REM in SEND_BILLS
TOGETHER TO DEFINE
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');
I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.
Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results
the query I wrote is this:
SELECT SEND.*
REC received_bills, send_bills send
WHERE send.datum = rec.datum
AND send.payment = rec.payment
AND send.code = rec.code
AND 'rec.status =' SUCCESS
;
The query results give me this
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 The result of the correct application would be
OCTOBER 10, 15 19 A1 OCTOBER 10, 15 25 A5 OCTOBER 10, 15 19 A1 The select statement that I need I want to use a loop to insert records in another table.
Can someone help me please?
Thanks in advance.
Best regards
Caroline
Want to get answers that work? Then make sure that the CREATE TABLE and INSERT statements you post too much work. Test (and, if necessary, correct) your statements before committing. You have a stray "." in the first INSERT statement for received_bills and receikved_bills.status is defined as VARCHAR2 (5), but all values are 6 characters long.
There are 5 lines in send_bills that are similar to the
10 OCTOBER 2015 19 A1
Why do you want that 2 rows like this in the output, not 1 or 3, or 4 or 5? Is it because there are 2 matching rows in received_bills? If so, you can do something like this:
WITH rec AS
(
SELECT the reference, payment, code
, ROW_NUMBER () OVER (PARTITION BY datum, payment, code)
ORDER BY NULL
) AS r_num
OF received_bills
Situation WHERE = 'SUCCESS'
)
send AS
(
SELECT the reference, payment, code
, ROW_NUMBER () OVER (PARTITION BY datum, payment, code)
ORDER BY NULL
) AS r_num
OF send_bills
)
SELECT send.datum, send.payment, send.code
REC, send
WHERE send.datum = rec.datum
AND send.payment = rec.payment
AND send.code = rec.code
AND send.r_num = rec.r_num
;
Note that the main request is very similar to the query you posted, but the last condition has changed.
If you need to insert these lines in another table, you can use this query in an INSERT statement. There is no need of a loop, or for any PL/SQL.
-
Quick loss of millions of records in a table with version
Hello world
We seek for one of our tables versioned delete and contains about 28 million records. On Exadata and 11.2.0.3.
Normally we would just drag the table, but there is a requirement that we keep a number of documents (about 500 k), complete with the story, so that other components of the system related are not lacking (even if these 500 k will also be removed subsequently).
I did a survey on how we can do that, but a massive factor is to ensure that there is minimal downtime. A method I've tried is to remove batch of 5 million - if the button Delete merging could take 24 hours in total for each series and we could not afford 6 cases of this.
I also tried DBMS_WM. PURGETABLE, but this seems to take a long time as well (even with no table to archive being created).
Copies the records in another table LT, truncate table source and re - insert the records back in 500 k is an option that we looked at, if not ideal. I think we would also update wm$ modified_tables for it.
Are there other alternatives that make this possible, or if we were to go down the road of truncated - is there anything else we need to consider in order to maintain the coherence of the WMSYS dictionary?
Many thanks in advance,
James
Hi James,
Would it not possible to simply do the operation to remove directly in LIVE workspace? This would eliminate the need to merge the workspace. Truncation operations do not rely on the tables of the activated version. Nor is face _LT table to a temporary table and the re-insertinig. The hierarchy of the workspace and other metadata may have changed in the meantime which would make it invalid reinserted data. Guaranteeing that nothing else changes it would fix, but is not yet all that is generally supported.
Delete that number of lines will take some time little matter method. How long the procedure PurgeTable did? It is going to be the approach that should be faster by using features of the Workspace Manager. In addition, if these lines will be deleted anyway, why not just wait until it is safe to do so and do it all at this point in time? Then you must conditionally delete lines. You can simply call dbms_wm. DisableVersioning on the table and then delete it.
Kind regards
Ben
-
How to count records in a Table or form
I have a Table that went to my context in the form of ADOBE. I need to be able to count the number of records in this table. I didn't see the actual table in this case on the shape, I just need than the number of records. And, I need to do this using JavaScript and I don't know anything about Java (although if FormCalc works I can use this as well). My Tablename is a customer and in my form, it's in the hierarchy data .main .customerbody .customerline. If I have to have these data in the table on the form, then I can just put it on the form and invisiible. I really need to count the number of records well and return this # to a text field in the form.
Does anyone know how to do this and can you give me an example is Java for FormCalc? The more specific you can be with the example script best for this beginner. THX!
I was no longer complicate things, and I found a simple answer to my problem. I do this on SAP with Livecyle form so here's what I did
In the Interface, I created a global variable called gv_count. I then added, during the initialization of form Interface, copy the following code:
describe the table reservations LINES gv_count.
And then, in the form, I had just to add gv_count to the context and how link this to the field I want to do the count
-
DB update multiple records in a table with a form
I'm developing an online proofing system that displays a number of images and then allow the client to approve each image, but also to comment.
I currently have a configuration table with the different elements (an image dynamically takes its name, details about the image and the required form fields). See this Image for layout
I would then apply a repeat region (the number of signs vary) and you want to update all records with feedback from the customer and approval with a single form. How this is done? I downloaded a trial of the Toolbox for developers, but the documentation is horrible. I'd be willing to buy an extension that will allow, as appropriate.
I found an extension that does this in two minutes:
http://www.WebAssist.com/Professional/products/ProductDetails.asp?pid=117
Great software, highly recommended. Easy to figure out and got this "problem" solved quickly.
-
SQL Query to retrieve records in a table with the same records or only one record in a table
Hello
Got a curious requirment to extract the Non-distincts records in a table
Example of
Account number Type of account 12345 SB 12345 SB
12346 CR 12346 SB 12347 SB 12348 CR 12349 SB Requrirement is to retrieve the records as follows
Result must be
Account number Type of account 12345 SB 12345 SB
12347 SB 12348 CR 12349 SB You will notice that 12346 which has two separate lines have been eliminated in the result. I tried several qeries to achieve this result, one or the other had a few mismatch. Can someone give me a request for it.
Thanks in advance.
SELECT ACCOUNT_NUMBER,
ACCOUNT_TYPE
DE)
SELECT ACCOUNT_NUMBER,
ACCOUNT_TYPE,
COUNT (*) ON CNT_ACC (ACCOUNT_NUMBER PARTITION).
COUNT (*) ON CNT_NUM_TYP (PARTITION ACCOUNT_NUMBER, ACCOUNT_TYPE)
FROM T1)
WHERE CNT_ACC = CNT_NUM_TYP;
exit;
12345 SB 12345 SB 12347 SB 12348 CR 12349 SB -
Best practices to save a record in a table with appropriate trigger
Hello
At the same time, five users enter customer information in a customer table through Oracle form. Customer table has the following fields:
CUSTOMER ID
NAME OF THE CUSTOMER
ADDRESS OF THE CUSTOMER
Automatically generates a CUSTOMER ID by calling a procedure. In this procedure, I use the MAX function to get the maximum value for the CUSTOMER ID. After that, I store the CUSTOMER ID say newly generated in a BLOCK of DATA element: MASTER. CUSTOMER ID.
The problem is that all five users receive same MAX CUSTOMER ID value(suppose 40) at the same time, and form of oracle probably will throw an exception when inserting the record in the customer table. The CUSTOMER ID is PK and he is a member of the MASTER DATA BLOCK.
I hope that all the above will be illustrated well the problem, complement, guide, peut prior INSERT trigger can deal with this problem effectively? , if so, then how? ...
Thank youHello
Automatically generates a CUSTOMER ID by calling a procedure. In this procedure, I use the MAX function to get the maximum value for the CUSTOMER ID. After that, I store the CUSTOMER ID say newly generated in a BLOCK of DATA element: MASTER. CUSTOMER ID.
In what trigger you generate CUSTOMER ID automatically. You must use the procedure which generates and assigns the CUSTOMER ID in PRE-INSERT-TRIGGER.
I hope that all the above will be illustrated well the problem, complement, guide, peut prior INSERT trigger can deal with this problem effectively? , if so, then how? ...
You can call the procedure say GET_CLIENT_ID in PRE-INSERT-TRIGGER, in this procedure you must have the following assignment statement:
:BLOCK_NAME.CLIENT_ID := V_CLIENT_ID;
Where V_CLIENT_ID is the value obtained by using MAX, as you said.
I hope this helps.
Best regards
Arif Khadas
-
Assemble the different tables with large amounts of data
Hello
I need to collect different types of tables:
Example "table1", with columns: DATE, IP, TYPEN, X 1, X 2, X 3
For "table0" with the DATE, IP, REFERENCE columns.
TYPEN in table1 to be inserted in REFERENCE in table0, but by a function that transforms it to another value.
There are several other tables like 'table1', but with slightly different columns, which must be inserted into the same table ("table0").
The amount of data in each table is pretty huge, so the procedure must be made into small pieces and effectively.
If / could I use data pump for this?
Thank you!user13036557 wrote:
How can I continue with this then?Should I delete the columns I don't need and transform the data in the first table, and then use data pump.
or should I just do a procedure traversing all ranks (into small pieces) "table1", then threading "table0"?
You have two options... Please test both of them, calculate the time to complete and to implement the best.
Concerning
Rajesh -
record in the table with time stamp
Hello
I use Forms6i and db 10g
I have a datablock in my form, which is based on a table hlp_user_master.
The table has fields crt_on, upd_on. who is date type.
Now I'm set sysdate to these areas, before saving it to the database.
He is now in the database, just.
But I want it to be like date with the time.
My Manager said to set the data type of the fields in the form.
I did the DateTime data type, in the form
but still in the database, just when saving
Help, pleaseHello
If you have changed in the form of the datetime data type and the mask format as I said in my previous post. Then, the database will have time also after saving it. I guess that you are checking in via SQL * more. If so, try the following query.SELECT TO_CHAR(DATE_COLUMN,'DD-MON-YY HH24:MI:SS'); FROM TABLE_NAME;
If the form is stalling as it will display then with time.
-Clément
-
delete a multiple record in slot table with checkbox form.
Hello guys,.
I need your suggestions...
I have the block master detail. (SECTION and INSTRUCTOR)
The retail block, I add checkbox element (name: RB_SECTION_ID) with part of database 'No' and when to check the value: SECTION_ID (on property).
I do a DELETE button. The trigger was the DELETION of the ARTICLE where section_id =: SECTION. RB_SECTION_ID and
instructor_id =: are you doing. INSTRUCTOR_ID;
but it does not work.
How delete us record multiple check multiple check box, and then click DELETE... ??
View.
NIA...Because your delete statement reflected until it is saved or re-queryied...
Add Lee after the END of the LOOP;
execute_query (no_validate); -
How to count the records for each region day and conditional
Hello
I need to create a report where I list activities for a month and the number of specific Type for each days activities. something like below
Number of days in the month where Type = 'A' Count where Type = B
January 1, 2009 2 3
January 2, 2009 7 6
January 3, 2009 8 7
----
-----
January 31, 2009 4 6
I tried with the creation of conditional region for each row of table for every day, but it does not work. I use below for conditional region-
<? xdofx:If substr (to_date ('20': substr (Planned, 9, 2) |)) » -'|| substr (Planned, 1, 2). » -'|| (substr (Planned, 4, 2), 'MM-DD-YYYY'), 4, 2) = 01? > <? Planned? > <? end if? >
But it is not functional and do not know how to count records in the table for each date as well.
Can anyone help in it as soon as possible. I'm quite new to BI.
ThnksYou can mark it as resolved... :D
Kind regards
Colectionaru -
help in registration of the records from two tables
HI: I have two tables joined the first field. The field is the primary key in the first table. Need help listing records from both tables with each a line/record results.
I want to print each record in the table of EVENTS such as a line and the corresponding records in EVENT_UPDATES as a line like this recordcreate table EVENTS ( event_key varchar2(64) primary key, event_description varchar2(64), create_time int ); create table EVENT_UPDATES ( event_key varchar2(64) NOT NULL , update_description varchar2(64), update_time int ); insert into EVENTS values('Event1', 'This is event1', 1); insert into EVENT_UPDATES values('Event1', 'Ticket created', 3); insert into EVENT_UPDATES values('Event1', 'Event cleared', 10); insert into EVENTS values('Event2', 'This is event2', 4); insert into EVENT_UPDATES values('Event2', 'Ticket created', 6); insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);
TIAEvent1 1 This is event1 3 Ticket created 10 Event cleared Event2 4 This is event2 6 Ticket created 8 Event cleared
Raviselect case weight when 1 then event_key end key, time_val, description from ( select event_key, create_time time_val, event_description description, 1 weight from events union all select event_key, update_time, update_description, 2 weight from event_updates ) order by event_key, weight / KEY TIME_VAL DESCRIPTION ---------- ---------- ------------------------- Event1 1 This is event1 3 Ticket created 10 Event cleared Event2 4 This is event2 6 Ticket created 8 Event cleared 6 rows selected. SQL>
SY.
Maybe you are looking for
-
Google Street Views flicker evil in whatever happened Firefox 28
Arrested upgrade to version 28 because Google Streetview (classic mode) flickers bad to any higher version. Because embedded in the Disqus post YouTube videos has recently stopped working in v28 I am obliged in a version that does not work for me. An
-
Good IP address of my router extreme need.
I watched the network TCP/IP section, however its is a short number in the router and not the number long normal 192. etc. which is necessary to be able to access the URL configuration thiungs. Does anyone know how to find the real IP address?
-
What pins to use to receive the data from the PDS ELITE RS485 with the PXI-8431/2?
Hello! I use the PXI-8431/2 to read data from the flow meter PDS ELITE (Modbus RTU). Receiving data, the RS485 protocol request to terminals 4 and 5, but this configuration does not seem to work. When I connect the RS-485 converter USB of Microflex I
-
newbie on a vi Lottery question
I was through the forum and found a few ways to do this, but I have a problem of table: I put mine to generate five initials and door numbers upward award-winning "powerball", but my question is how can I get the table five to see each number in anot
-
several times I have ti home page of silverlight to check updates, but whenever the UAC has poped upward and asked to let silverlight accsess but when I try to click on it to say yes or any other thing UAC froze upwards and I can not do something els