SQL & PL/SQL :: Include / Exclude In One Query Statement
Aug 31, 2011
how to write this query using all three tables in one query statement.
Result:
Input value of "GM" would return "GM@EMAIL.COM"
Input value of "GM" and "GMC" would return "GMC@EMAIL.COM"
If "GM" is supplied, then only return the "GM@EMAIL.COM" email.
If "GM" and "GMC" is supplied, then only return the "GMC@EMAIL.COM" email
Test Case : GM would return "GM@EMAIL.COM" email
Test Case : GM and GMC would return "GMC@EMAIL.COM" email
select email
from email a,
company b,
sub_company c
where (company = "GM" but no match found in sub_company)
(company = "GM" and sub_company_name = "GMC" match is found in sub_company)
Is there any difference between include program header before CREATE OR REPLACE PACKAGE statement and program header after CREATE OR REPLACE PACKAGE statement
Are some posibilities to exclude duplicate values do not using sql aggregate functions in main select statement? Priview SQL statement
SELECT * FROM ( select id,hin_id,name,code,valid_date_from,valid_date_to from diaries )
[Code]....
In this case i got duplicate of entry TT2 id 50513 In main select statement cant use agregate functions are even posible to exclude this value from result modifying only the QLRST WHERE clause (TRUNC need to be here)
I have to do a number of database exercises and it's my very first time using SQL. I did all of them, except for one query.It's fairly simple, I need to find for every combination of warehouses (there are 5) and items (25) how many of each items I can stock in said warehouse until until it goes over the capacity. So for example warehouse 1 has a max of 300 pounds and item 1 weighs 1 pound, so I can stock 300 in it. Warehouse 1 and product 2...etc.
Every warehouse has a capacity in pounds and every item has a weight also in pounds. There are 3 tables between warehouse and items (warehouse---shipment---order----order details----items).
I managed to find every instance of warehouse_ID/item_ID/(capacity/weight)...but thats for the existing warehouses/item. If they added a new warehouse or product, I'd be screwed, as they wouldnt show up in my query...here's my query:
select Warehouse_ID, item_ID, (select round(capacity/weight,1) as maximum_capacity from order_detail join item using (item_ID) join order using (Order_ID) join shipment using (shipment_number) join warehouse using (warehouse_ID) group by warehouse_id, item_id order by warehouse_ID
I keep trying to find a way to include possible new warehouses or products in my query, but I'm at a complete loss. I tried to right and left outer joins with no luck
Here is my problem : I have 7 applications to deploy on Forms server, each with there own applicationsX.env file. In formsweb.cfg, I specify an envFile directive in each applications specific section.The problem is that I would prefer not to copy default.env 7 times just to add 2-3 specific directives. I would like to always include default.env + applicationsX.env for example.
Is there a way to specify multiple env file in the envFile directive?
I want to creat a table using Execute Immediate that includes tablespace name in the create table command. But I don't know the tablespace name that the client is using. Can I incorporate in a script? If yes, then how?
I have written the following proc. While executing , it gives me the error: ORA-00959: tablespace 'V_TABLESPACE_NAME' does not exist.
create or replace procedure pr_create_table as v_tablespace_name varchar2(4000); begin select distinct tablespace_name into v_tablespace_name from user_tables where table_name like 'ABC%'; [code]....
However when I run this I do not see the sys.aud$ in the log file. I know I can do a seperate export to specifically get the sys.aud$ table but is there any way to include it in with my full export?
I am using oracle 11.2.0.3.0, i have taken database backup using rman , after backup i have added a new datafile . My database has been crash , can i restore the database including the new data file which does not include in backup . I have all the archive logs.
I'm trying to modify my dbca template to include two control files. One on ASM +RECO and we we're thinking of adding the second one on the database filesystem $ORACLE_BASE/something/something Within the template there are references to controlfiles two places:
With this configuration there is only one controlfile created and that is on +RECO. What am I doing wrong and also should I add the second controlfile to +DATA instead of fielsystem $ORACLE_BASE?
We've got a query which returns one row, but uses an IN statement. The IN statement links to more than one row in the subquery. When we use a combination of DISTINCT and an ANALYTICAL sum, the sum total is multiplied by the number of rows in the sub query. Remove the DISTINCT and we get a single value.
A simplified example of the problem is below.
I can't see how a query which returns a single row then returns multiple values with the addition of a DISTINCT. Removing the analytical sum also provides a single row, but we need this in the actual query we're running. So it seems to be some combination of DISTINCT, ANALYTICAL SUM and IN query is causing multiple values to be returned.
CREATE TABLE go_test_distinct1 (gtd_value NUMBER); -- Three identical values -- To replicate the three identical values returned by
#select name from v$database; #select log_mode from v$database; #select count(*)"INVALID_OBJECTS" from dba_objects where status='INVALID'; #select count(*) "INVALID_N/A_INDEXES" from dba_indexes where status!='VALID'; #select count(*)"Invalid Triggers" from user_objects where OBJECT_NAME like '%TRIGGERS%' and status='VALID'; #select count(*) "Broken Jobs" from dba_jobs where broken!='Y'; #select count(*) "Block Corruption" from v$database_block_corruption;
i want a table which can be generated just by select cmd and it will list the result of all the above queires as follow:-
I mean to say i want multiple select queries into 1 table (note:- i m not saying to create a tables and then insert,update(using select from other tables), its just a sheel script that will fetch these record into a txt file)
The "HAVING" statement from the query below removes all rows where the "name" field starts with "Port" and it removes all rows where count is less than 11. What I want is to removes all rows where the "name" field starts with "Port" and the count for that row is less than 11.
SELECT deviceEventClassId "Event ID", deviceAddress "Device Address", name "Event Name", deviceHostName "Device Host Name", count( concat(deviceEventClassId, deviceHostName, name)) "Count" FROM events WHERE (deviceVendor = "Bilbo" and
I've seen this example numerous places, and tried to implement it, but I keep getting an "invalid identifier" error message, despite the fact that I've got the table and column specifically identified.For instance, my query reads like:
UPDATE tbl1 SET tbl1.EMPID = (SELECT tbl2.EMPIDA FROM tbl2 WHERE LOWER(tbl1.EMAILCOL) = LOWER(tbl2.EMAILCOL2) ) WHERE tbl2.EMPIDA IN ('Z1O435','S8M4722','M0D5156') AND EXISTS (SELECT tbl2.EMPIDA FROM tbl2 WHERE tbl1.EMAILCOL= tbl2.EMAILCOL2 );
But I'll keep getting flagged at the tbl2.EMPIDA column reference. I have not tried this in SQL Plus, just in TOAD, but it seems to repeatedly fail.I have had to dump records to standalone Access tables and link back to perform the updates.
I have a table zTEST with several products and ID's. Now I want to exclude all products which are in table zTEST_EXCL and have ID's up to ID+2. The Result is then in table zTEST_RESULT.
I'm using pivot query feature of oracle 11g and came across a strange situation where i need to pass a "select statement" in a "in clause" of pivot query.
I have tried with pivot xml but it not giving desired output in sql*plus session.It is giving unreadable output.
select * from (select uin,testing_id,pfa_result from test1) pivot xml (max(pfa_result) as result for (testing_id) in (select distinct testing_id from test1));
[code]....
Here actually i want to use "select distinct id from test1" instead of "in (11,12,13,14,15)". Because i don't know how many id's will be there and of which values. e.g. 11 or 21 or 25.
if it is possible to include 'data' files as part of the Application Export process. Up till now I've only been able to include supporting object files which will recreate a table structure but not the data records - I've been creating the latter outside of APEX.
I need to exclude several tables with specific prefixes, all the tables where names do not starts with 'A_' or 'B_' or 'C_'I tried this:
EXCLUDE=TABLE:"NOT LIKE 'A!_%' ESCAPE '!' and NOT LIKE 'B!_%' ESCAPE '!' and NOT LIKE 'C!_%' ESCAPE '!'" I have this errors: ORA-39001: invalid argument value ORA-39071: Value for EXCLUDE is badly formed. ORA-00936: missing expression ORA-06512: at "SYS.KUPM$MCP", line 3174