Select statement help for sql/oracle newbie
I have a db for a fake airline. i have a route table that has columns for "FIRST_CLASS_FARE", "COACH_FARE", and "ECONOMY_FARE". I then have a flight table that references the route#, then a trip table that references the flight#. I also have a passenger table and a reservation table that has the passenger # in it. The reservation table also has a column called "reservation class" that has a 'f' for first class fare, 'c' for coach fare, 'e' for economy fare.
What I am trying to do is create a fill for each individual passenger that shows the total amount they spent on all of their reservations.
Any suggestions on how to join the tables to create this bill?
Thanks in advance!
Is it the way the passenger table has columns and is populated,
for a passenger A, takes a route - 1 with First class fare - $2500 on flight- B123, to a trip - t1 and reserved for class - 'f'
If this is the way, then you get the bill from the fare column
Similar Messages
-
Help for an Oracle Newbie???
Hi there,
Sorry for probably a ridiculously stupid question but my boss has asked me to ask on here! Here goes -
We have a network with around 100 users. Previously we have used MS Access to report on our database, the users then logged into Access Reports and ran the required report. We are now looking at using Oracle Discoverer or similar. We have installed the developer suite and have downloaded Oracle Application Server 10g. We are able to create queries using discoverer and reports using the report builder.
My question is this - once i have created my reports (in .jsp format i believe), is it possible to host these using the application server?
The users need to log into a website or similar and select the report they need to run.
Any help would be appreciated - as i say, sorry for probably a silly question!!
Many thanks,
James.Hi!
The answer is yes and the details on how is in the docs, see the link below.
http://download-east.oracle.com/docs/cd/B14099_19/bi.1012/b14048/toc.htm
It would be a too lengthy thread trying go through all the details...
You can also publish your Discoverer Workbooks using Portal as the frontend publishing platform
http://download-east.oracle.com/docs/cd/B14099_19/bi.1012/b14465/toc.htm
/Mikael -
Multiple Select statements in EXECUTE SQL TASK in SSIS
Can we write multiple select statements in execute sql task(SSIS).
If possible how to assign them to variables in result statementHi ,
You can use below steps to set result set to variable.
1.In the Execute SQL Task Editor dialog box, on the General page, select the Single row, Full result set, or XML result set type(According to your result set).
2.Click Result Set.
3.To add a result set mapping, click Add.
4.From the Variables Name list, select a variable or create a new variable.
What is multiple selection ? May be below can be used in your scenario !
http://stackoverflow.com/questions/17698908/how-to-set-multiple-ssis-variables-in-sql-task
What you want to achieve ?
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com -
How to use the select statement in for loop
Hi All,
my question is can we use select statement in for loop like as follows .
for key in select key from one_table.
when i am using this am getting an error like Found select invalid i identifier
how to make use of select statement in for loop
please suggest me .
Thanks
SreeSQL>set serveroutput on;
SQL> DECLARE
BEGIN
FOR Cur_Rec IN (SELECT dname FROM dept) LOOP
DBMS_OUTPUT.PUT_LINE(Cur_Rec.dname);
END LOOP;
END;
SQL>
ACCOUNTING
RESEARCH
SALES
OPERATIONSAs per your requirement always filter the Query beforehand
Like
FOR Cur_Rec IN (SELECT key FROM <table> WHERE key=1) LOOP
END LOOP;Edited by: Lokanath Giri on १ दिसंबर, २०११ ३:५६ अपराह्न -
Select statements inside a SQL Expression field
Hello
Why cannot we use the Select statements inside a SQL expression field in Crystal Reports ?
Any alternatives for this...
SELECT Top(1) "SomePrivateDatabase"."SPDname" FROM "SomePrivateDatabase"
inner join "Subscriber" on
"Subscriber"."SPDID" = "SomePrivateDatabase"."SPDID"
inner join "UserDetails" on
"UserDetails"."SPDID" = "SubscriberCore"."SPDID"
Regards
Srivatsa
Edited by: Srivatsa Haridas on Dec 3, 2008 12:17 PMHi Srivatsa,
SQL Expressions is something the Database supports. We query the Client engine for a list of functions they make available. If the SQL Statement is not list it's not an option and therefore it won't work.
Your work arounds are to use either a Stored Procedure, this is the most efficient way, all processing is done server side and CR simply waits for the data to format in the report. Another option is to use a
Command Object, use one CO per report so try to get all data within the SQL statement. We simply pass the SQL to the server and wait for the result set, if you get an error it will be the SQL you typed in. Test in a SQL test tool first to confirm you are getting the data correctly.
For more assistance in designing reports please post your report deisgn questions to the Reprot Design forums. I am moving this one to that queue.
Thank you
Don -
Need help for SQL SELECT query to fetch XML records from Oracle tables having CLOB field
Hello,
I have a scenario wherein i need to fetch records from several oracle tables having CLOB fields(which is holding XML) and then merge them logically to form a hierarchy XML. All these tables are related with PK-FK relationship. This XML hierarchy is having 'OP' as top-most root node and ‘DE’ as it’s bottom-most node with One-To-Many relationship. Hence, Each OP can have multiple GM, Each GM can have multiple DM and so on.
Table structures are mentioned below:
OP:
Name Null Type
OP_NBR NOT NULL NUMBER(4) (Primary Key)
OP_DESC VARCHAR2(50)
OP_PAYLOD_XML CLOB
GM:
Name Null Type
GM_NBR NOT NULL NUMBER(4) (Primary Key)
GM_DESC VARCHAR2(40)
OP_NBR NOT NULL NUMBER(4) (Foreign Key)
GM_PAYLOD_XML CLOB
DM:
Name Null Type
DM_NBR NOT NULL NUMBER(4) (Primary Key)
DM_DESC VARCHAR2(40)
GM_NBR NOT NULL NUMBER(4) (Foreign Key)
DM_PAYLOD_XML CLOB
DE:
Name Null Type
DE_NBR NOT NULL NUMBER(4) (Primary Key)
DE_DESC NOT NULL VARCHAR2(40)
DM_NBR NOT NULL NUMBER(4) (Foreign Key)
DE_PAYLOD_XML CLOB
+++++++++++++++++++++++++++++++++++++++++++++++++++++
SELECT
j.op_nbr||'||'||j.op_desc||'||'||j.op_paylod_xml AS op_paylod_xml,
i.gm_nbr||'||'||i.gm_desc||'||'||i.gm_paylod_xml AS gm_paylod_xml,
h.dm_nbr||'||'||h.dm_desc||'||'||h.dm_paylod_xml AS dm_paylod_xml,
g.de_nbr||'||'||g.de_desc||'||'||g.de_paylod_xml AS de_paylod_xml,
FROM
DE g, DM h, GM i, OP j
WHERE
h.dm_nbr = g.dm_nbr(+) and
i.gm_nbr = h.gm_nbr(+) and
j.op_nbr = i.op_nbr(+)
+++++++++++++++++++++++++++++++++++++++++++++++++++++
I am using above SQL select statement for fetching the XML records and this gives me all related xmls for each entity in a single record(OP, GM, DM. DE). Output of this SQL query is as below:
Current O/P:
<resultSet>
<Record1>
<OP_PAYLOD_XML1>
<GM_PAYLOD_XML1>
<DM_PAYLOD_XML1>
<DE_PAYLOD_XML1>
</Record1>
<Record2>
<OP_PAYLOD_XML2>
<GM_PAYLOD_XML2>
<DM_PAYLOD_XML2>
<DE_PAYLOD_XML2>
</Record2>
<RecordN>
<OP_PAYLOD_XMLN>
<GM_PAYLOD_XMLN>
<DM_PAYLOD_XMLN>
<DE_PAYLOD_XMLN>
</RecordN>
</resultSet>
Now i want to change my SQL query so that i get following output structure:
<resultSet>
<Record>
<OP_PAYLOD_XML1>
<GM_PAYLOD_XML1>
<GM_PAYLOD_XML2> .......
<GM_PAYLOD_XMLN>
<DM_PAYLOD_XML1>
<DM_PAYLOD_XML2> .......
<DM_PAYLOD_XMLN>
<DE_PAYLOD_XML1>
<DE_PAYLOD_XML2> .......
<DE_PAYLOD_XMLN>
</Record>
<Record>
<OP_PAYLOD_XML2>
<GM_PAYLOD_XML1'>
<GM_PAYLOD_XML2'> .......
<GM_PAYLOD_XMLN'>
<DM_PAYLOD_XML1'>
<DM_PAYLOD_XML2'> .......
<DM_PAYLOD_XMLN'>
<DE_PAYLOD_XML1'>
<DE_PAYLOD_XML2'> .......
<DE_PAYLOD_XMLN'>
</Record>
<resultSet>
Appreciate your help in this regard!Hi,
A few questions :
How's your first query supposed to give you an XML output like you show ?
Is there something you're not telling us?
What's the content of, for example, <OP_PAYLOD_XML1> ?
I don't think it's a good idea to embed the node level in the tag name, it would make much sense to expose that as an attribute.
What's the db version BTW? -
Hi,
we are running a query with a big dunamic select statement from VB code using ADO command object. When Execute method is called system hangs and control won't return back to the application. it seems to be that there is some type limitation on Query string length. Please tell us if there is any?
we are running Oracle 8.1.7 Server on Windows 200 Server and connecting from a W2K professional, ADO 2.6 and Oracle OLEDB 8.1.7.1 OLEDB Driver.
Sample code:
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Set cmd = New Command
With cmd
.CommandText = ' some text with more than 2500 characters
.CommandType = adCmdText
Set rs = .Execute
End With
when i debug using VB6 and when .Execute line is called system hangs or return a message method <<somemethod> of <<some class name>> failed error.
Any help is appreciated.
Thanks,
AnilA stored procedure would only slow you down here if it was poorly written. I suspect you want to use the translate function. I'm cutting & pasting examples from the documentation-- a search at tahiti.oracle.com will give you all the info you'll need.
Examples
The following statement translates a license number. All letters 'ABC...Z' are translated to 'X' and all digits '012 . . . 9' are translated to '9':
SELECT TRANSLATE('2KRW229',
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'9999999999XXXXXXXXXXXXXXXXXXXXXXXXXX') "License"
FROM DUAL;
License
9XXX999
The following statement returns a license number with the characters removed and the digits remaining:
SELECT TRANSLATE('2KRW229',
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789')
"Translate example"
FROM DUAL;
Translate example
2229
Also, LIKE '%<string>%' is going to be rather expensive simply because it has to compare the entire string and because it forces full table scans, rather than using indexes. You could speed this sort of query up by using interMedia Text (Oracle Text now in 9i). If you can eliminate one of the '%' options, you could also improve things.
My guess is that your stored procedure is inefficient and that's causing the problem-- 5k rows per table should be pretty trivial.
If you post your query over on the PL/SQL forum, there are better performance tuners than I that might have more hints for you. To get really good advice, though, you'lllikely have to get at least the execution plan for this statement and may need to do some profiling to identify the problem areas.
Justin -
Multiple select statements in PL/SQL
Hi All
I am new to PL/SQL and my experience is in writing TSQL. There we can write a SQL statement like this to return 3 result set
SELECT empname FROM Employee
SELECT authname FROM Author
SELECT athname FROM sport
how can we write the same 3 statements in PL/SQL and attain the 3 resultsets.
I tried to implement the same using PL/SQL anonymous blocks. But it didn't worked.
DECLARE
P_RECORDSET OUT SYS_REFCURSOR
BEGIN
OPEN P_RECORDSET FOR
SELECT empname FROM Employee;
SELECT authname FROM Author;
SELECT athname FROM sport;
END;
can anybody show how it can be done.
Thanks in advance
George
Edited by: user6290570 on Sep 16, 2009 11:23 PMgeorge2009 wrote:
No i just want to select 3 result sets from 3 select statements, so that it is helpful to compare the resultsets. Compare? How? This is done using the SQL language. Not PL/SQL. Not Java. Not VB. Not anything else.
You would use these other language for flow control and certain forms of conditional logic - but the actual comparison of data sets is done in SQL.
Of course, that is if you do want to do it the most optimal way, that will perform well, and scale well.
SQL is not an I/O API layer - to be used to read() a record and write() a record as if the RDBMS is an ISAM file. That form of row-by-row and slow-by-slow processing dates back to the 80's when we used Cobol.. (or at least for those old farts like me that can actually remember coding in Cobol in the 80's ;-) ).
You want to design and code database applications that are fast, robust, and can scale? Then learn how to use SQL correctly. -
MySQL Select Statement Help Required
I am trying to generate a report in VS 2008 (C#) using a mysql select statement but cannot get it right.
I have groups that meet on a weekly basis on different days. I want to generate a report that shows me all the members that have not attended their group where they have missed 3 meetings in a row.
Below is the select statement I have tried but it does not give me the results I am looking for. I have tried to look at all the meetings in a 4 week period but would prefer to look at the last 3 meetings that are recorded. Some groups might not record a meeting every week. So I want to look at the last 3 recorded meetings and count each members attendance and only report on the members with more than 3 meetings missed.
SELECT COUNT(`groupattendance`.`Attended`) AS Attendance, `smallgroupform`.`MeetingDate`, `userinfo`.`FirstName`, `userinfo`.`Surname`, `smallgroup`.`GroupName`, `groupattendance`.`Attended`, `groupattendance`.`UserID`, `groupattendance`.`GroupID`
FROM ((`anatomy`.`groupattendance` `groupattendance`
INNER JOIN `anatomy`.`smallgroupform` `smallgroupform` ON `groupattendance`.`FormID` = `smallgroupform`.`FormID`)
INNER JOIN `anatomy`.`userinfo` `userinfo` ON `groupattendance`.`UserID` = `userinfo`.`UserID`)
INNER JOIN `anatomy`.`smallgroup` `smallgroup` ON `groupattendance`.`GroupID` = `smallgroup`.`GroupID`
WHERE (`smallgroupform`.`MeetingDate` >= DATE_SUB(CURDATE(),INTERVAL 4 WEEK) AND `smallgroupform`.`MeetingDate` <= CURDATE()) AND `groupattendance`.`Attended` = 'False'
GROUP BY `userinfo`.`UserID`
HAVING Attendance >= 3
Thanks,
Garth.Hi Garth,
Seems no one can help you directly. Try googling your SQL request. Someone may be able to help you. At this point its not really a Cr problem.
One option is to get all the data and add filtering using the record selection formula.
Thank you
Don -
Combine two select statements in one SQL statements
I have the following two queries that I need to combine into one query, where it updates a single row at the same time.
SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = "4837"
SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = "4837"
I want to insert the values of each select statement into two columns of the same row, as well as insert the account number from the select statement.
After the query has been executed, the database row will look like this:
ACCOUNT COUNT SUM
4837 354 1039202
I am looking for suggestions on how to:
- either combine the two into one query
- simply update each column with the value from each query by updating the row with the account value
I am a SQL newbie - so I appreciate any assistance.
Thanks,
TonyHi, Tony,
When you're talking about changing the data in tables, "INSERT" means to add a new row, and you'll cause a lot of confusion if you use it to mean something else. So don't say
"I want to insert the values of each select statement into two columns..."; use some other word, like:
"I want to put the values of each select statement into two columns ..."
If you happened to know that those two numbers were 354 and 1039202, you might say:
UPDATE table_x
SET a_count = 354
, a_sum = 1039202
WHERE account = 4837;But you don't know the numbers; you want to have the query figure out what they are.
In most places where you can use a literal (like 354 or 1039202), you can also use a scalar sub-query, a SELECT statement, enclosed in parentheses, that produces one column and (at most) one row.
In your case, you can say:
UPDATE table_x
SET a_count = (SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = 4837)
, a_sum = (SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = 4837
WHERE account = 4837;or, to make it more readable:
UPDATE table_x
SET a_count =
( SELECT count (*)
FROM database.USAGE
WHERE SERVICE_TYPE = 'C'
AND ACCOUNT = 4837
, a_sum =
( SELECT sum (minutes)
FROM database.USAGE
WHERE SERVICE_TYPE = 'DA'
AND ACCOUNT = 4837
WHERE account = 4837;By the way, why are you using double-quotes around 4837? If it's a string, enclose it in single quotes. If it's a number (which I'm assuming in my code), don't enclose it in anything.
WARNING: scalar sub-queries are somewhat like duct tape: they're extremely useful in certain places, and those places account for about 1% of their use. The other 99% of the time, there's a better way to do things, though the better way may require more expertise. -
Enhancing standard (single select)search help for Multiple value selection
Hi,
Standard search help for Business Partner (in cProjects) allows only single value selection for input fields. I want to make this multiple selection.
Is there a way to do it.
I used an OVS and built a similar search but its difficult to get the standard options like saving to personal value list etc in it.
It would be good if there is a way to modify the standard search help to allow multiple selection. Any ideas??
Appreciate your help,
Thanks,
Sri
Edited by: Sri on Sep 9, 2010 8:50 PM
Edited by: Sri on Sep 9, 2010 8:52 PMAs far as I know you can't make a standard ABAP dictionary search help return multiple entries - where you get this sort of functionality the searches don't use the standard Elementary search help framework (e.g. organisational structure searches)
Given that the WDA search help relies on these dictionary based searches, I'd think very much that you couldn't enhance it to return multiple. how you could even return multiple entries into a single UI element input field is also confusing to me.
I'd suggest creating a freely programmed value help, it would certainly take quite some effort to recreate those personal value lists etc, but it could be done - I don't like OVS, but that just me. -
Need help for importing oracle 10G dump into 9i database
hi, Someone help me to import oracle 10G dump into 9i database. I'm studying oracle . Im using oracle 10G developer suite(downloaded from oracle) and oracle 9i database. I saw some threads tat we can't import the higher version dumps into lower version database. But i'm badly need help for importing the dump...
or
someone please tell me the site to download oracle 9i Developer suite as i can't find it in oracle site...I didnt testet it to import a dump out of a 10g instance into a 9i instance if this export has been done using a 10g environment.
But it is possible to perform an export with a 9i environment against a 10g instance.
I am just testing this with a 9.2.0.8 environment against a 10.2.0.4.0 instance and is working so far.
The system raises an EXP-00008 / ORA-37002 error after exporting the data segments (exporting post-schema procedural objects and actions).
I am not sure if it is possible to perform an import to a 9i instance with this dump but maybe worth to give it a try.
It should potentially be possible to export at least 9i compatible objects/segments with this approach.
However, I have my doubts if this stunt is supported by oracle ...
Message was edited by:
user434854 -
Need help for finding oracle payables tables
Hi,
I need help for finding tables relating fields INVOICE_ID, NOTIFICATION_ID and APPROVAL_STATUS or WFAPPROVAL_STATUS. I have searched a lot but has been unable to find any table containing all the above mentioned fields. I found the table WF_NOTIFICATIONS for INVOICE_ID, however have been unable to find the latest tables with INVOICE_ID and APPROVAL_STATUS as fields.
All the tables having this combination are either very old tables which are not used anymore or doesnt give the required data. Please let me know where am i going wrong. Once i get the required tables, i need to join the tables to get the required data with the imp fields. Also, the values of WFAPPROVAL_STATUS are not very clear to me. I need values for it as APPROVED, REJECTED AND INITIATED.Hi Swetha,
You will have to manually make the table adjustments in all the systems using SE14 trans since the changes done using SE14 cannot be collected in any TR.
How to adjust tables :
Enter the table name in SE14. For ex for any Z master data(Say ZABCD), master data table name would be /BIC/PZABCD, text table would be /BIC/TZABCD. Similarly any DSO(say ZXYZ) table name would be /BIC/AZXYZ00 etc.
Just enter the table name in SE14 trans --> Edit --> Select the radio button "Save Data" --> Click on Activate & adjust database table.
NOTE : Be very careful in using SE14 trans since there is possibility that the backend table could be deleted.
How to collect the changes in TR:
You can collect only the changes made to the IO --> When you activate, it will ask you for the TR --> Enter the correct package name & create a new TR. If it doesn't prompt you for TR, just goto Extras --> Write transport request from the IO properties Menu screen. Once these IO changes are moved successfully, then the above proceduce can be followed using SE14 trans.
Hope it helps!
Regards,
Pavan -
Probelm facing in Zprogram select statements developed for PBS conversion
Hi,
Am using PBS conversion tool to convert the Report programs for Archive. In that program am having select statement for KONV table which takes KWERT and KSCHL based on KNUMV. In this case PBS conversion tool is not able to do the conversion and this where needs manual editing is necessary, becoz KNUMV and KSCHL which are used for selection are not supported as index fields.
Kindly suggest how to proceed ..
Thanks in Advance.NAME1,
STRAS,
MCOD2
MCOD3
LAND1
TELF1
TELFX
FOR KNA1
namev, name1 for knvk table
name1, street, house_num1, str_suppl1, city1, country post_code1 for adrc table
vbeln for vbak table
/cwm/pikmg, /cwm/pikme for lips table -
Oracle Know-How in SAP world for a Oracle newbie
Hi forum,
I would like to increase my Oracle know-how in SAP world. I've already a good experience with SAP on MSSQL, DB/2 on iSeries. I've a good know-how on SPARC/Solaris, SPARC/Linux, Intel/Linux, iSeries and Intel/Windows also in cluster.
I've just already try to install CRM/SCM/ECC IDES ORACLE system on Windows as my personal test without problems, but now I would like to know better Oracle for SAP.
Where can I find Oracle for SAP documentation ? do you suggest me a book ? I try to read a Oracle press book but it is so hard because many of Oracle features are not used by SAP. I need a know-how to manage to instal and managed a landscape (syscopy, backup, ecc.)
Thank you for attention.
Regards.
Ganimede Dignan.beside Eric suggestions also following links can be helpful.
http://www.oracle.com/newsletters/sap/archive.html
http://www.oracle.com/newsletters/sap/service.html
http://www.oracle.com/newsletters/sap/events.html
http://www.oracle.com/newsletters/sap/index.html
https://metalink.oracle.com/
SAP documentations about Oracle and SAP Notes (about especially Oracle FAQs):
e.g:
<b><u>592393</u></b> - FAQ: Oracle
<u><b>700548</b></u> - FAQ: Oracle authorizations
<b><u>562863</u></b> - FAQ: Logon mechanisms
<b><u>666061</u></b> - FAQ: Database objects, segments and extents
<b><u>606395</u></b> - FAQ: Oracle Limitations
etc....
and many other notes about Oracle FAQs and Oracle basics can help you.
Maybe you are looking for
-
MMS Not Working After 4.2 Update (Lost my Unlimited Plan, too!)
Ah, the return of the new and improved "Viewmymessage.com" After updating to the new 0S 4.2, I not only lost the ability to send and receive MMS messages (I checked, it's turned on under settings|messages|MMS), but AT&T has conveniently dropped me fr
-
I just did a fresh install of Arch, ran "pacman -Syy" and it returned the error: Inconsistency detected by ld.so: ../sysdeps/x86_64/dl-machine.h: 466: elf_machine_rela_relative: Assertion `((reloc->r_info) & 0xffffffff) == 8' failed! Any Ideas? The o
-
SRM 7.0 Invoice Rejection in SRM Portal
Hi, We have come across a scenario where an approver is unable to reject an invoice in their tasks queue. An error message of "/sapsrm/cx_pdo_error Reason for rejection is mandatory" appears However, when they reject a Shopping Cart for example, it w
-
Java FX + Request + Applet
Hello, I develop a simple Chat that sends the Chat Msg to a server and write it into a database. After that the read the 10 newest messages and response these as string... In Netbeans it works greatly (Standard Exceution).. but If I change it to "Run
-
List of Important Tables in ABAP
Hi, Can anyone send me a List of Important Tables in ABAP. Thanks & Regards, Sai