Please help :( finding the diference between a table value and a count
Ok... Pretty much, atm I am trying to make a view which is a capacity (specified by a table) minus a count(*) of all the tables, what I am doing is getting the capacity and atempting to take it away from a joined table which contains all of the people booked into a certain flight.. I know it sounds crazy, but I'm sure (surely hopeful) it will work..
To sum my question up, how can I make a view which has one table minus a numerical result from a count(*)... If I can that is.
EDIT:
I have made somthing which could be possibly ported into a function which returns the correct answer.. maybe is it better/possible to make the view somehow start a function?
Edited by: 893357 on Oct 26, 2011 11:17 AM
How about starting with this "design" (I came up with it in 20minutes so it can be refined further)
FLIGHT_MASTER
(FLIGHT_NUMBER VARCHAR2(6) primary key,
FROM_CITY_CD VARCHAR2(6),
TO_CITY_CD VARCHAR2(6)
FLIGHT_DETAILS
(FLIGHT_ID NUMBER primary key,
FLIGHT_NUMBER VARCHAR2(6) foreign key references FLIGHT_MASTER (FLIGHT_NUMBER),
SCHEDULED_DEPARTURE DATE,
ACTUAL_DEPARTURE DATE,
TOTAL_SEATS NUMBER(4,0),
BOOKED_SEATS NUMBER(4,0)
FLIGHT_BOOKINGS
(PNR VARCHAR2(6) primary key,
FLIGHT_ID NUMBER foreign key references FLIGHT_DETAILS (FLIGHT_ID),
SEATS_BOOKED NUMBER(4,0)
PASSENGER_DETAILS
(PASSSENGER_ID NUMBER primary key,
PNR VARCHAR2(6) foreign key references FLIGHT_BOOKINGS (PNR),
TICKET_TYPE_FLAG VARCHAR2(3),
PASSENGER_FIRST_NAME VARCHAR2(30),
PASSENGER_SECOND_NAME VARCHAR2(30),
PASSENGER_LAST_NAME VARCHAR2(30),
PASSENGER_PHONE VARCHAR2(30),
PASSENGER_ADDRESS_1 VARCHAR2(60),
PASSENGER_ADDRESS_2 VARCHAR2(60),
PASSENGER_ADDRESS_3 VARCHAR2(60),
PASSENGER_CITY VARCHAR2(60),
PASSENGER_COUNTRY VARCHAR2(60)
select fm.flight_number, fm.from_city, fd.flight_id, fd.scheduled_departure, fd.total_seats,
fd.total_seats - fd.booked_seats available_seats
from flight_master fm, flight_details fd
where fm.flight_number='&flight'
and fd.scheduled_departure = '&scheduled_date_time'
and fm.flight_number=fd.flight_number
-- whenever a new reservation is made (only if available_seats >= required_seats)
select from flight_details for update of booked_seats where .....
insert into flight_bookings ...
insert into passenger_details ...
... store the number of seats in a variable :purchased_seats
update flight_details set booked_seats = booked_seats + :purchased_seats
commitHemant K Chitale
Similar Messages
-
Need to find the Difference between two table
Hello ,
I have stucked in program as below scenario:-
I have two tables of huge data of same structure in a same schema.I need to find the difference exact values in tables.
By using MINUS we can find the difference between two table ,i need to find the what exact difference in the there values with colunm and value at that column.
Example TableA
Col1 col2 col3 col4 col5.... col50
10 ABC 2001 EE 444 TT
40 XYZ 3002 RR 445 TT3
80 DEF 6005 YY 446 YY8
TableB
Col1 col2 col3 col4 col5.... col50
10 ABC 2001 EE 444 TT
40 XYZ 3002 RR 445 TT3
81 DEF 6005 Yu 447 YY8
I need to the out put like this :-
The Diffence between two table is
TableA.COL1=80 TableB.Col1=81, Different
TableA.Col4=YY TableB.col4=Yu,Different
TableA.Col5=446TableB.col5=447,Different
Please suggest me to write the pl/sql program for the same
thanx in advance
KKThanx friends for all your efforts
I have a sample code for the same,this will compare the two tables for single row in each table .
what r the modification needed for the multiple rows of values in the two tables??
Please suggest!!
CREATE OR REPLACE PROCEDURE test_compare
IS
TYPE t_col
IS
TABLE OF VARCHAR2 (30)
INDEX BY PLS_INTEGER;
l_col t_col;
j NUMBER := 0;
l_sql VARCHAR2 (2000);
col1 VARCHAR2 (30);
col2 VARCHAR2 (30);
val1 NUMBER;
val2 NUMBER;
status VARCHAR2 (30);
CURSOR c1
IS
SELECT column_id, column_name
FROM all_tab_columns
WHERE table_name = 'TEST1';
BEGIN
FOR i IN c1
LOOP
j := j + 1;
l_col (j) := i.column_name;
END LOOP;
FOR k IN 1 .. j
LOOP
l_sql :=
'SELECT '
|| ''''
|| l_col (k)
|| ''''
|| ', '
|| 'TEST2.'
|| l_col (k)
|| ', '
|| ''''
|| l_col (k)
|| ''''
|| ', '
|| 'TEST1.'
|| l_col (k )
|| ', '
|| 'DECODE(TEST2.'
|| l_col (k)
|| ' -TEST1.'
|| l_col (k)
|| ', 0, ''NO CHANGE'', ''CHANGED'') FROM TEST2, TEST1';
EXECUTE IMMEDIATE l_sql INTO col1, val1,col2, val2, status;
IF status = 'CHANGED'
THEN
DBMS_OUTPUT.put_line( 'TEST2.'
|| col1
|| '='
|| val1
|| ', TEST1.'
|| col2
|| '='
|| val2
|| ', '
|| status);
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error:- ' || SQLERRM);
END;
/ -
Please help find the program to block unwanted number, call and SMS, that not all block number ,but the number on which you want to.
Which part of "The 5310 is just a java phone that cannot support applications like this." did you not understand?
If you want to achieve any form of blocking at all, it won't be with that phone. Your operator may be able to help by putting a block in place on their end, though, but I doubt it.
Was this post helpful? If so, please click on the white "Kudos!" star below. Thank you! -
Please help find the IMEI number
By email:
Please?
My Iphone was stolen
Call
AIS network
(Thailand)
thank you very much
<Personal Information Edited by Host>http://support.apple.com/kb/HT1267
Regards. -
How to find the mapping between External Object Name and Business Obj.
Hello Gurus
Anyone who can help me? I would like to know is there any way to know Business Object is behind object associated to Context Node, it seems that for some cases is easy but for instance for object BuilHeader is not the case, at least for me. View BP_ADDR/StandardAddress, which belongs to UI Component BP_ADDR, has context node HEADER which is associated to BuilHeader. In case to enhance that object (to add new attributes), using EEWB, I need to know what is the business object behind that external name. Somehow I cannot find the mapping between external name BuilHeader and Business Object.
Kind regards
AleksandarHi Aleks,
If you want to enhance Business Partner, the object you are looking at should be "BUPA" in EEWB. To my knowledge, there is no place where this kind of mapping is maintained.
Note 484597 describes where to find the Cookbook which describes the enhanceable objects and the enhancement process.
In case your requirement is to add table attributes, you can also take a look at the wiki link:
http://wiki.sdn.sap.com/wiki/display/CRM/EEWB-AddingTableattribute
Regards,
Nisha -
PLEASE HELP. The connection between invoices and notifications
Hi
I have to develope a search page for invoice notifications. The trouble is that I can't find the connection between an invoice and the notifications sent on this invoice. Have no connection between the WF_NOTIFICATIONS table and the AP_INVOICES_ALL and AP_INVOICE_DISTRIBUTIONS_ALL tables. Is there anyone that can please help me ?In the Report Builder, try
File --> Generate to File --> HTML
for an approximation of "what you see is what you get". There may be differences from what the end user sees based on different browsers (IE vs Netscape), different browser margin and font settings and different printers for printed reports. It is truly annoying. We have found that PDF is more predictable when it can be used instead of HTML. -
How to find the difference between 2 time values in Java
hi all,
i have 2 time values
String time1="6:20";
String time2="21:30"
How to find the difference between 2 times in Java?
pls help
thanx in advance....Calculating Java dates: Take the time to learn how to create and use dates
Working in Java time: Learn the basics of calculating elapsed time in Java
Formatting a Date Using a Custom Format
Parsing a Date Using a Custom Format -
How to find the relation between that tables
Hi,
I have to get the data from different tables but I dont have any table relation ship. So If any body can help me to get that relation ship that will be very helpful for me.
my tables are
LFA1
LFB1
LFC1
RFSDO
BSIK
Thanks
Imran>
SURINDER SINGH OBEROI wrote:
> Hi,
>
> LFA1-LIFNR = LFB1-LIFNR = LFC1-LIFNR = BSIK- LIFNR
> LFB1-BUKRS = LFC1-BUKRS = BSIK-BUKRS
> LFC1-GJAHR = BSIK-GJAHR
> LFC1-ERDAT = BSIK-AUGDT
>
> Cheers,
> Surinder
You think, you can fetch accurate data with the above mentioned linkages?
Oh btw, the question i believe the question was How to find the relation....
pk -
Please help finding the Flash program in Toronto
Hello everybody!
Can anyone direct me to a College that has the best program
(full-time/ part-time- up to 1-2 years, but not distant) in
Web-design, particularly in Flash. I'm searching such program in
Toronto and 'll be thankfull for any information you can give.I'm no expert on Flash, but I can tell you some basic stuff
you should know:
1. most universities will not teach flash.
2. the professors who do teach flash preferred Actionscript 2
over Actionscript 3. I don't know how they feel about AS4, but it
seems the skeleton/reverse kinematic features are a really big hit
even with the glitches.
3. Flash is like Rome. Your knowledge of it will not be built
in a day, no matter how shiny the speaker's teeth may be.
Based on these three points, you should look for something
that familiarizes you with Object Oriented Programming, Web Design,
Animation, and Multimedia. You probably know all this stuff
already, but you want to avoid the guy who says for $750 bucks his
2 hour seminar will make you a pro. For $750 bucks you should
expect a full multi week course with multiple days each week,
several course objectives, a final project, and some textbooks to
boot. Cut the textbook down to 1 manual from Barnes & Noble and
pick up the programs from here:
http://www.studentdiscounts.com/index.asp?PageAction=VIEWCATS&Category=791 -
Find the difference between previous row value
Hi All,
I have a Property Rent Review table which holds the last rent update done on a property.
I need to be able to compare the rent change (%) at any interval for a property. - so the query should allow to pull the property rent at 2 or more points in time and I need a view that shows % increase or decrease between the 2 dates.
Generally the dates would be 3 months apart (qtrly) but I would like to be able to enter my own dates in case I want to run monthly / annually or compare “before” and “after” the Rent Review.
Below is a sample data
TenantCode PropCode Rent Charged Rent Change Date
31163 2469 157.68 6/01/2014
31163 2469 160.69 16/06/2014
31163 2469 162.65 1/12/2014
51428 2469 162.65 10/12/2014
50824 3174 160.69 28/03/2014
50824 3174 160.69 4/04/2014
50111 3174 149.5 21/05/2014
50695 3852 256.5 24/01/2014
50695 3852 327.87 10/03/2014
50695 3852 256.6 31/03/2014
50804 3865 278.48 18/03/2014
50779 3865 236.67 21/05/2014
50804 3865 237.82 31/07/2014
51135 3865 237.82 21/08/2014
51135 3865 165.69 12/09/2014
51135 3865 230.15 17/11/2014Hi Diegoctn,
Your query work perfectly. But can we get the view as Patricks view below
With
CTE
AS
SELECT
ROW_NUMBER()OVER
(PARTITIONBYProp_Code
ORDERBYDATE_CHANGED_SQL)ASSeq,
FROM
R23
SELECT
c1.PROP_CODE,c1.TENANT_NUMB,c1.TOT_DEB_VAL,c1.DATE_CHANGED_SQL,(c1.TOT_DEB_VAL
-c2.TOT_DEB_VAL)*100.0/NULLIF(c2.TOT_DEB_VAL,0)
AS[Rent(%)]
FROM
CTE c1
LEFT
JOINCTE
c2
ON
c1.PROP_CODE
=c2.PROP_CODE
AND
c1.Seq
=c2.Seq
+1
Where
c1.PROP_CODE
='1587' -
How to find the relation between tables
Hi
I am working in Oracle R12
How to find the relationship between these tables INV_MIN_MAX_TEMP,po_requisition_lines_all and Per_all_people_f
These two table i have joined with po_requisition_lines_all and Per_all_people_f To_person_id from PO and Person from hr table but i cant able to join this table with other tables INV_MIN_MAX_TEMP
regards
SrikkanthHi;
Please check e-trm site for table relation,integration,explanation etc..
etrm.oracle.com/
Regard
Helios -
How to find the difference between Project costs & Cost center costs?
Hi all,
Can you please explain me ? What is project Cost & Cost center cost and which are the tables having those fields of project cost & cost center Costs? And how to find the difference between their costs ? And please give me the functional Idea about it?
Thanking you all in Advance...
Regards,
ChandruHi,
goto table COSP:
1) object-no. beginning with 'KS' refer to cost-centre
example: 'KSKOKA4711'
with KS, KOKA = controlling area and 4711 = cost centre
2) OBJNR beginning with 'PR' refer to projects / WBS-element
example PR00001234
Message was edited by: Andreas Mann -
What's the diference between Mac pro and iMac?
I am really confused with this two things.
I dont know what a Mac Pro is, but I thing is like a CPU?, I mean, can I conect it to my iMac?
I'm really lost.
Can someone exaplain what's the diference between those two?
and do I can conect to my iMac?
also any full explanation of what a Mac Pro is would be really helpful.My iMac specs:
http://gyazo.com/a99277dd2c7e8e2616d984d9b83f283c
http://gyazo.com/e125027d64b99e44be7b81bc91ce81f3
http://gyazo.com/cc81c911df1760d38fcd00a2ce184064
What I do on my iMac is:
Gaming, Maya, After Effects, Nuke, Photoshop, Boujou, Realflow, 3DS Max (soon)
Most of the time working with heavy 3D and Videos.
I wanted to buy other 4GB Ram, and a Quadro 4000 (but its for Mac pro).
My idea was (or still is) to buy a Mac Pro and expand my iMac capacity (processors, Ram, etc, but no one has answered me if i can do that), or else I was thinking if I can buy the Mac Pro and transfer my iMac stuff to it, then use the iMac monitor as a display of the Mac pro just while the iMac sells and then just buy a monitor (but again, no one has answered me if I can do that too)
Please solve my questions -
What is the differrence between NI motion asst and motion dev module for labview?
Hi,
Could you please tell me the difference between Ni motion assistant and soft Motion development module for LabVIEW also the application areas of both.
Thanx
MukeshHello Mukesh,
Do you mean the SoftMotion Development Module for LabVIEW? FlexMotion and SoftMotion are two totally different methods of creating a motion system. FlexMotion uses a motion controller board (PCI or PXI). The software interfaces with the board. On the board there is a lot of processing that is done (ie: PID control). The board interfaces with the motion drive. In a SoftMotion system, there is no motion controller board. You need to use some other I/O technology (ie: DAQ, FieldPoint, RIO, etc) to interface directly from the software to the motion drive. All of the processing that was done on the motion controller is now done in the software.
So FlexMotion is an API to help your software interface with a motion controller board. SoftMotion is an API that enables your software to process data in a motion system (ie: process it the way that a motion controller would).
Motion Assistant is an application environment (separate from LabVIEW) that allows you to set up a sequence motion commands through dialog boxes. You can set up a motion process and test it in Motion Assistant. It is capable of building LabVIEW code for the same motion system. There is also an API that allows you to control Motion Assistant from LabVIEW programmatically.
I hope this information helps. Please let me know if you have any further questions about this issue. Take care!
Regards,
Aaron B.
National Instruments -
What is the difference between Fixed Costed, Costed and Distributed?
Hi Friends,
Can someone please tell me the difference between Fixed Costed, Costed and Distributed?
ThanksCheck under heading 'Costing' on HRMS guide, link is here
http://docs.oracle.com/cd/A60725_05/html/comnls/us/per/defelw04.htm
thanks
Maybe you are looking for
-
Generate Multiple Invoices in One PDF
Hi, I have requirement whereby I need to generate multiple invoices in one PDF file. I am using Oracle BI Publisher with Oracle APEX 4.0.2 If there is only one invoice that needs to be generated in one PDF file then I already have the solution whereb
-
I want my phone to be completely silent. If I flick it on to wilent it doesn't vobrate when it rings which is great and it doesn't vibrate when a message comes through. However, it does beep when a text comes through which I don't want, plus I don't
-
Hi, Can any one suggest the solution to get the workflow items in the portal UWL. I had configured the UWL and I am able to get the mails of the documents in the inbox of SAP. But I am not able to get the workflow items. Even I had maintained the tas
-
I want to back up all my photos to a flash drive - how to do?
I have PSE8 and am running Win7 64 bit laptop. I want to back up all my photos to a flash drive. I can't seem to do this within my PSE8, just gives me the option of copying to a CD or DVD. Should I be doing this from My Pictures or can I do this in P
-
MBP 2007 thinks wireless router password is incorrect
Yes... I have checked the password a BILLION times. I do have the password right but it thinks I don't. I've been connecting to this router for 8 months problem free. Now it says I have the password wrong. I have reset it loads of times to try to fix