Thing is how can I join those tables to get all the sales ID's that have at least two products one of which has got any number of messages and the other one hasn't got ANY any messages. So another words one sale entity that has both products with messages and at lease one with no message. Something like this
Sales 1 ID 123 Product1 ID 1234 for sale ID 123 Product2 ID 4321 for sale ID 123 Sales_message ID 098 for product ID 1234 'blabla' Sales_message ID 876 for product ID 1234 'albalb' AND NO MESSAGES FOR PRODUCT 4321
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
insert into sample values('1','01-JAN-2005'); insert into sample values('1','1-JAN-2006'); insert into sample values('2','2-JAN-2007'); insert into sample values('3','4-JAN-2005'); insert into sample values('4','11-JAN-2004'); insert into sample values('3','2-JAN-2005'); insert into sample values('2','12-JAN-2006'); insert into sample values('1','21-JAN-2005'); insert into sample values('2','11-JAN-2005'); insert into sample values('7','01-JAN-2005'); [code]....
I am trying to create view that selects a number of rows from a table and has a calculated field which is a counter form 1 to n next to each row.
In the below example, s_name is repeated many times each with a differnet serial, I want to cteate a view that shows a counter for the occurences of s_name next to the serial.
CREATE TABLE XYZ ( SERIAL NUMBER PRIMARY KEY, S_NAME VARCHAR2(30) ); INSERT ALL INTO XYZ VALUES (1, 'ABC') INTO XYZ VALUES (11, 'ABC')
Query 1: SELECT DISTINCT YR FROM( SELECT TO_CHAR( ADD_MONTHS (TRUNC (TO_DATE('01/01/2007' ,'DD/MM/YYYY'), 'YYYY'), 1*LEVEL -1) , 'YYYY') YR FROM Dual CONNECT BY LEVEL <= MONTHS_BETWEEN(TO_DATE(:to_dt ,'DD/MM/YYYY'), TO_DATE('01/01/2007' ,'DD/MM/YYYY')) + 1 ORDER BY YR )
Gives the Output as YR **** 2007 2008 2009 2010 2011
Query 2 ******* SELECT DISTINCT MONTH FROM( SELECT TO_CHAR( ADD_MONTHS (TRUNC (TO_DATE('01/01/2007' ,'DD/MM/YYYY'), 'MM'), 1*LEVEL -1) , 'MM') MONTH FROM Dual CONNECT BY LEVEL <= MONTHS_BETWEEN(TO_DATE(:to_dt ,'DD/MM/YYYY'), TO_DATE('01/01/2007' ,'DD/MM/YYYY')) + 1 ORDER BY MONTH ) Gives the Output as
I have an excel spreadsheet that queries an oracle data for some information. I am trying to get the information shown to only be from the current month. I have tried my google-fu, but all of the formulas I have found will not work and return a various error of some sort. The rest of the query works great, but I cant figure this one out. Select*From&& and I guess i need a where statement, but nothing seems to work.Where"My_Table_Name","OrderDate".
My form Consists data block blk_user with two items username and password
Both user name and Password are required Fields.
When user left these items Empty To show Alert
I Created Below Procedure and Called in Form_Level ON-ERROR Trigger.
PROCEDURE pcd_io_alert IS itm_name VARCHAR2(20); BEGIN
[Code].....
how to call or create this procedure as Library functions and call the created library in form To Show Alert. Actually I want to create library functions to Validate and Show Alert Mesages.
I want a monthly report where the month wise sum of qty should be displayed in a row for last 12 months. I need to specify the month start date and end date in the query to pick the sum for the particular month. How can i do it in a SQL query?
SUM(decode(to_char(t1.trx_date,'mm/rrrr'), to_char(add_months(SYSDATE, -1),'mm/rrrr'), nvl(t2.quantity_invoiced, 0))) AS qty_01 from t1,t2 where t1.col1=t2.col1
instead of sysdate i have to use start and end of month. Also i am using group by clause on some columns.
SELECT HISTORY_ID ,SUM(MISSED_SCHOOL) AS MISSED_SCHOOL,SUM(MISSED_SCHOOL_LAST) AS MISSED_SCHOOL_LAST FROM EMRASTHAMAHISTORYDETAILS WHERE ------ GROUP BY HISTORY_ID
There is no date column in table using sysdate alone need to retrieve last 6 month records
sql statement to query a transaction table that stores transactions of items bought from my organisation.The report i would like to generate is one that lists the items bought and this should be grouped month by month.
We have a requirement where we need to pay allowance for the employees based on their number of working days. Say for example if an employee worked from 03/Mar/2012 to 05/Apr/2012.
We have a fixed value for per month 300 Dirhams. But the Number of Days on March s 31 and Number of days in April is 30. So per day allowance for March day would be 300/31 and April would be 300/30.
We are looking for logic opr query which calculates first eh number of days in each month ( across months) and then calculate as below
Number of Working days in March is 31 - 3 + 1 = 29
Allowance A1 = (300 * 29 )/31
Number of Working days in April is 5 ( this also needs to find logical I am guess ) Allowance A2 = (300 * 5 )/30
Then A1 + A2.
The A(n) would be the total allowance where provided the number of month across.
MISSING_DATES EMPNO ---------------------- ---------- 09-SEP-12 TO 11-SEP-12 7499 23-SEP-12 TO 26-SEP-12 7499 01-sep-12 TO 30-SEP-12 7521 01-sep-12 TO 30-SEP-12 7788
?I have the following requirement, the output should be:
Ticket count (sr_number) % of tickets inside DL Number of tickets inside DL Average cycle time (cycle time = closed date - created date) Total cycle time (cycle time = closed date - created date) Number of reassignments (sum)
DL - (deadline) formula is, closed date <= target_date
This should be displayed, grouped by year, then month and then by assignment group. The values should be in descending order(dates) Not sure how group by will work here.I am able to write the basic code for the above, but group by based on year, month and assignment group is pretty confusing to me.
INSERT INTO tra VALUES (2, 20503, SDO_GEOMETRY (2001, NULL, SDO_POINT_TYPE (1387, 0, NULL), NULL, NULL), 23037 ) /
and( position) indexed as Rtree spatial index
now when i run spatial query such as
SELECT * FROM tra t WHERE SDO_FILTER(t.position, MDSYS.SDO_GEOMETRY(2001,NULL,NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3), MDSYS.SDO_ORDINATE_ARRAY(0,0,9000,0)), 'querytype=WINDOW') = 'TRUE' and t.position.sdo_point.X=1;
i do not know how many IO accrued ?
i tried set autotrace on
but the physical read is 0 , this is not possible because i have more than 100000 objects there and all indexed as R-tree
I am getting a following odd result where the same a Job could be linked to multiple enquiries. What I want it to show is just one job if its linked to multiple enquiries. I show you some sample result:I wrote the following SQL for it:
SELECT 'Enquiry' as Origin, job.job_number, enquiry.enquiry_number as Defect_or_Enquiry, job.site_code, central_site.site_name, job.priority_code, priority.priority_name, job.target_comp_date, 'Target Completion Date required' as Due_Date [code]....
Is there anything you would add so that it shows just a unique job number where the job has multiple enquiries linked to it? I tried putting SELECT DISTINCT but that did not work.
I need to create a report that will show all activity for the day that the report is run. The report will be run or auto-refreshed throughout the day. So, at 10am, 11am, 2pm, 4pm etc. I just need to display quantities received, shipped etc. for that same day. Since the report will not be run at a fixed time, I can't use sysdate - .5 for example.
i got problem that i want to know Metadata in my Oracle DB 2 version there're OracleDB 9i and OracleDB 10g ,So i want to know about sql command to show all metadata of these Database, because i want to list My metadata and improve to Metadata's Standard(ISO/IEC 11179). How can i show all metadata of these database. is it the same sql command line with this 2 version Database to show all metadata?
me in building a query. I want to show the result of the query just like pivot table. Test case CREATE TABLE CPF_YEAR_PAYCODE ( CPF_NO NUMBER(5), INC_DATE DATE, PAYCODE_TYPE CHAR(1 BYTE),
[code]...
I want that my query should look like the format as attached in the xls sheet.
I'm trying to install additional Oracle products on my XP VM, but it is telling me to kill all running oracle products. It states that by running the Oracle utility: oradim80 or the Windows NT service Control Panel I can stop all of these services, but I cannot find either.
select t1.c1 as gr1, t2.c1 as gr2, t1.c2 from test_data t1,test_data t2 where t1.c1<>t2.c1 and t1.c2=t2.c2 and (select count(*) from test_data t3 where t3.c1=t1.c1)= (select count(*) from test_data t4 where t4.c1=t2.c1) order by 1 asc, 2 asc
but I don't find the way to refilter to group the data as expected. The idea is find subsets and show the set of data and values in column c1.
I have a requirement to list the data month wise dynamically where month data is also in the same table, hopefully the below posts should bring more clarity to my requirements.