Can u help in SQL Query
HI,
I need to insert some of the data from Table I to Table O by doing before i need to group five fields based on this group i should insert Table I fields. How can i solve this query? pls help.
Thanks in Advance.
in case you are not doing a group by on all columns you have to use a group-function on those fields not included in group by clause, i.e. :
insert into test (a,b,c,d,e,f)
select a,b,c, max(d), min(e), sum(f)
from facts
group by a,b,c
Similar Messages
-
Can anybody provide the SQL query to find the files uploaded in a particular folder?
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
NevinNevin,
Be great if we could know the version of Portal. For Rel. 1, here's the query
select id,masterthingid from wwv_things
where siteid = &site
and cornerid = &corner
&site - Content Area id
&corner - Folder id
if you don't know the folder id, use
select id from wwv_corners where siteid = &site
and name = &folder
Hope this helps. I have run into this situation before. Usually, the culprits were
one of the following:
1. Junk Characters in description of item (caused due to Copy-Paste)
2. Special Characters in the File name
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
Nevin -
Can I put a SQL query into a bind variable and then use it to output report
Hi,
Can I put a SQL query into a bind variable and then use it to output report?
I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
select * from (:P1_TEXT);
Do you think it is possible to do that? Any known limitations for APEX in this area?
Thanks a lot,
AngelaYou can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
Tyler -
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
Can anyone help me with Query ?
Hi Experts,
Can anyone help me with Query? the query need to retrieve below info based on set of books ID.
Needed columns:
1 SOB
2 Legal Entities
3 Fixed Asset Org Name
4 Applications/Responsibilities
5 Operating Units
6 Inventory Org
7 COA
8 Assigned Responsibilities
ThanksDuplicate post -- Can you help on below Query ?
Please post only once! -
Can you help on below Query ?
Hi Experts,
Can anyone help me with Query? the query need to retrieve below info based on set of books ID.
Needed columns:
1 SOB
2 Legal Entities
3 Fixed Asset Org Name
4 Applications/Responsibilities
5 Operating Units
6 Inventory Org
7 COA
8 Assigned Responsibilities
ThanksAlthough this is not a complete query, it will give you a start
select haou.name "Name",'Legal Entity' "Type", gsb.name "Set Of Books"
from hr_all_organization_units haou,
hr_organization_information hoi,
gl_sets_of_books gsb
where haou.organization_id = hoi.organization_id
and hoi.org_information_context = 'Legal Entity Accounting'
and hoi.org_information1 = gsb.set_of_books_id
and gsb.set_of_books_id = :sob
UNION
select haou.name "Name",'Operating Unit' "Type", gsb.name "Set Of Books"
from hr_all_organization_units haou,
hr_organization_information hoi,
gl_sets_of_books gsb
where haou.organization_id = hoi.organization_id
and hoi.org_information_context = 'Operating Unit Information'
and hoi.org_information3 = gsb.set_of_books_id
and gsb.set_of_books_id = :sob
UNION
select haou.name "Name",'Inventory Org' "Type", gsb.name "Set Of Books"
from hr_all_organization_units haou,
hr_organization_information hoi,
gl_sets_of_books gsb
where haou.organization_id = hoi.organization_id
and hoi.org_information_context = 'Accounting Information'
and hoi.org_information1 = gsb.set_of_books_id
and gsb.set_of_books_id = :sob
UNION
select fifs.id_flex_structure_name "Name",'Chart Of Account' "Type", gsb.name "Set Of Books"
from fnd_id_flex_structures_vl fifs,
fnd_id_flexs fif,
gl_sets_of_books gsb
where fif.application_id = fifs.application_id
and fif.id_flex_name = 'Accounting Flexfield'
and fifs.id_flex_num = gsb.chart_of_accounts_id
and gsb.set_of_books_id = :sobOther tables which would help you are fnd_application_tl and fnd_responsibility_tl
HTH -
Hi guys can someone help with a query regarding the 'podcast app' why do they not have all the episodes that relate to one show available why only half or a selected amount
THanks...but some days they have all the episodes right back to the very first show...ive downloaded a few but they are only available every now and then which makes no sense...why not have them available the whole time ??
-
HELP! SQL Query: Other ways to reorder column display?
I have a SQL query report with a large number of columns (users can hide/show columns as desired). It would be great if the column display order could be changed by changing the order of the columns in the SELECT list in the Report Definition, but that doesn't work -- it puts changed or added columns at the end regardless of the order in the SELECT list of the query.
Is there some other way to reorder the columns displayed without using the Report Attributes page? It's extremely tedious to move columns around using the up/down arrows which redisplays the page each time. Am I missing a way to change display order, or does anyone have a "trick" to do this? It's so painful....
When defining forms you can reoder columns by specifying a sequence number for each column. Just curious as to why reports were not done the same way, and are there any plans to address this in a future release?
KarenYes, reordering columns is extremely painful.
It is supposed to be much improved in the next version.
See
Re: Re-ordering columns on reports
Moving columns up/down in Report Attributes
See my example at
http://htmldb.oracle.com/pls/otn/f?p=24317:141
Basically, let the users move columns around until they are blue in the face, provide a Save button to save the column order in a user preference and reorder the columns when the page reloads.
Or you can use Carl's PL/SQL shuttle as the widget to specify the columns shown and their order. The shuttle is at http://htmldb.oracle.com/pls/otn/f?p=11933:27
Hope this helps.
Message was edited by:
Vikas -
Hi,
I need a help in writing an SQL query . I am actually confused how to write a query. Below is the scenario.
CREATE TABLE demand_tmp
( item_id NUMBER,
org_id NUMBER,
order_line_id NUMBER,
quantity NUMBER,
order_type NUMBER
CREATE TABLE order_tmp
( item_id NUMBER,
org_id NUMBER,
order_line_id NUMBER,
open_flag VARCHAR2(10)
INSERT INTO demand_tmp
SELECT 12438,82,821,100,30 FROM dual;
INSERT INTO demand_tmp
SELECT 12438,82,849,350,30 FROM dual;
INSERT INTO demand_tmp
SELECT 12438,82,NULL,150,29 FROM dual;
INSERT INTO demand_tmp
SELECT 12438,82,0,50,-1 FROM dual;
INSERT INTO order_tmp
SELECT 12438,82,821,'Y' FROM dual;
INSERT INTO order_tmp
SELECT 12438,82,849,'N' FROM dual;
Demand_tmp:
Item_id org_id order_line_id quantity order_type
12438 82 821 100 30
12438 82 849 350 30
12438 82 NULL 150 29
12438 82 0 50 -1
Order_tmp :
Item_id org_id order_line_id open_flag
12438 82 821 Y
12438 82 849 N I need to fetch the records from demand_tmp table whose order_line_id is present in order_tmp and having open_flag as 'Y' or if order_type in demand_tmp table is 29.
The below query will give the records whose order line id is present in order_tmp. But, If i need records which are having order_type=29 the below query wont return any records as order_line_id is NULL. If I place outer join I will get other records also (In this example order_type -1 records) . Please help me how can we write a query for this. Expected o/p is below.
Query :
Select item_id,org_id,order_line_id,quantity,order_type,open_flag
from demand_tmp dt , order_tmp ot
where dt.order_line_id = ot.order_line_id
AND dt.item_id=ot.item_id
AND dt.org_id = ot.org_id
AND ot.open_flag = 'Y';
Expected Output :
item_id org_id order_line_id quantity order_type open_flag
12438 82 821 100 30 Y
12438 82 NULL 150 29 NULL Thanks in advance,
Rakesh
Edited by: Venkat Rakesh on Oct 7, 2012 6:32 PM
Edited by: Venkat Rakesh on Oct 7, 2012 8:39 PMHi Rakesh,
the query is not working as you would like ( but IS working as expected ) since your trying to compare null to another value.
Comparing null always results in FALSE, also if you compare null to null. This is because null means undefined.
select 1 from dual where null=null results in no data found.
I would suggest using a non natural key to join the tables.
For example include a column ID in the master table which is filled with a sequence and include that field as a foreign key in the detail table.
This way you can easily join master and detail on ID = ID, and you don't have to worry about null values in this column since it's always filled with data.
Regards,
Bas
btw, using the INNER JOIN and OUTER JOIN syntax in your SQL makes it better readable, since you're separating join conditions from the where clause, just a tip ;) -
Can't write right sql query by two tables
Hello
Everyone,
I am trying to get a sql query by two tables,
table:container
<pre class="jive-pre">
from_dest_id number
ship_from_desc varchar
to_dest_id number
</pre>
table: label_fromat (changeless)
<pre class="jive-pre">
SORT_ORDER number
PREFIX varchar2
VARIABLE_NAME varchar2
SUFFIX varchar2
LF_COMMENT varchar2
</pre>
the sql which i need is
a. table CONTAINER 's each column should have LABLE_FORMAT 's PREFIX before and SUFFIX back ,and these columns is connected
example : the query output should be like this :
<pre class="jive-pre">
PREFIX||from_dest_id||SUFFIX ||PREFIX||ship_from_desc||SUFFIX ||PREFIX|| to_dest_id||SUFFIX
</pre>
every PREFIX and SUFFIX are come from LABEL_FORMAT's column VARIABLE_NAME (they are different)
column SORT_ORDER decide the sequence, for the example above: Column from_dest_id order is 1, ship_from_desc is 2,to_dest_id is 3
b. table LABEL_FORMAT's column VARIABLE_NAME have values ('from_dest_id','ship_from_desc','to_dest_id')
If table CONTAINER only have one record i can do it myself,
But actually it is more than one record,I do not know how to do
May be this should be used PL/SQL,or a Function ,Cursor ,Procedure
I am not good at these
Any tips will be very helpful for me
Thanks
SavenHi, Saven,
Presenting data from multiple rows as a single string is called String Aggregation . This page:
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
shows many ways to do it, suited to different requirements, and different versions of Oracle.
In Oracle 10 (and up) you can do this:
SELECT REPLACE ( SYS_CONNECT_BY_PATH ( f.prefix || ' '
|| CASE f.variable_name
WHEN 'FROM_DEST_ID'
THEN from_dest_id
WHEN 'SHIP_FROM_DESC'
THEN ship_from_desc
WHEN 'TO_DEST_ID'
THEN to_dest_id
END
|| ' '
|| f.suffix
, '~?'
, '~?'
) AS output_txt
FROM container c
CROSS JOIN label_format f
WHERE CONNECT_BY_ISLEAF = 1
START WITH f.sort_order = 1
CONNECT BY f.sort_order = PRIOR f.sort_order + 1
AND c.from_dest_id = PRIOR c.from_dest_id
saven wrote:If table CONTAINER only have one record i can do it myself,
But actually it is more than one record,I do not know how to do In that case, why did you post an example that only has one row in container?
The query above assumes
something in container (I used from_dest_id in the example above) is unique,
you don't mind having a space after prefix and before from_dest_id,
you want one row of output for every row in container, and
you can identify some string ('~?' in the example above) that never occurs in the concatenated data. -
i am trying to write sql query for a single recordset.
I have an items table with all the standard item info and an item_colorID.
i have a color_lookup table with 2 columns, item_colorID and color_ID
i have a colors table with 2 columns, color_ID and color
i want to join the tables and filter it so that a repeat region shows dynamic data of item name, description, thumb, price
and also a list/menu dynamically populated by color
filtered so that each item shows in the list/menu only the colors that the item has available.
i have tried different variations of this sql
SELECT * FROM items INNER JOIN color_lookup ON color_lookup.item_colorID = items.item_colorID INNER JOIN colors ON colors.color_ID = color_lookup.color_ID WHERE items.itemCatID = 3 ORDER BY items.itemName
but the list/menu shows every color choice multiplied by the number of items in that color
ie White will show 80+ times.
thanks for your help,
jim balthropbregent,
thanks for your help.
I am building a shopping cart and i have a recordset to list the items and a repeat region for that recordset
i have a second recordset for the colors joined to the item_colorID nested inside the repeat region.
the shopping cart software has a 'lookup from recordset' choice for the add to cart servior behavior
and then i bind to the columns on the cart page.
it produces this code
if (isset($totalRows_rs_itemscat3) && $totalRows_rs_itemscat3 > 0) {
$row_rs_itemscat3 = WAEC_findRecordMySQL($rs_itemscat3, "item_ID", $ATC_itemID);
if ($row_rs_itemscat3) {
$ATC_itemName = "".$row_rs_itemscat3['itemName'] ."";// column binding
$ATC_itemDescription = "".$row_rs_itemscat3['itemShortDesc'] ."";// column binding
$ATC_itemWeight = floatval("".$row_rs_itemscat3['itemWeight'] ."");// column binding
$ATC_itemQuantity = "".$_POST["Farrington_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_rs_itemscat3['itemPrice'] ."");// column binding
$ATC_itemThumbnail = "".$row_rs_itemscat3['itemThumb'] ."";// column binding
$ATC_itemcolorchoice = "".$row_rs_colors['color'] ."";// column binding
mysql_data_seek($rs_itemscat3, 0);
$row_rs_itemscat3 = mysql_fetch_assoc($rs_itemscat3);
the column binding for the colors is from a different recordset and when redirecting to the cart page the color info will not show.
So my thinking is if i could get the color list/menu to populate from the same recordset as the item listing, it would solve my add to cart server behavior.
Is it possible to do this with only one recordset?
the products page and the cart page can be seen
http://www.farrington-enterprises.com/rain-gutters.php
add an item to the cart with any color choice and the color info does not carry to the cart. -
I have a table with Columns as as below
id number primary key
object_name varchar2(100)
object_value varchar2(100)
Data is stored as follows
id object_name object_value
10 prop_num 436
20 city dallas
40 Misc 1 90
50 Misc 1 desc min amount
60 Misc 2 700
70 Misc 2 desc interest amount
80 Misc 3
80 Misc 3 desc
SQL should return result as shown below
id object_name object_value
10 prop_num 436
20 city dallas
40 min amount 90
50 interest amount 700
I have done this through plsql code by creating temp table. But I need to do it in a sql query. I am stuck here
Any pointers/help is appreciated
Thanks
Edited by: user9327712 on Mar 11, 2010 8:14 AMI have a table where the ids are stored.
*"object name"* column values are actually another table columns stored as rows here. So in our example prop_num, city,Misc 1, Misc 1 desc, Misc 2, Misc 2
desc,Misc 3 , Misc 3 desc are all columns. These would not change any time
The column object_value has values stored for respective columns.
436, dallas , 90 , min amount , 700 , interest amount are all column values. So these can change.
id object_name object_value
10 prop_num 436
20 city dallas
40 Misc 1 90
50 Misc 1 desc min amount
60 Misc 2 700
70 Misc 2 desc interest amount
80 Misc 3
90 Misc 3 desc
Edited by: user9327712 on Mar 11, 2010 9:57 AM
Edited by: user9327712 on Mar 11, 2010 10:00 AM
Edited by: user9327712 on Mar 11, 2010 10:00 AM -
Complete novice needs help getting SQL Query into Crystal Reports XI
Post Author: MissMarnie
CA Forum: Data Connectivity and SQL
So I was given an intro level web course and a monster reference guide in prep to format a report. One of our developers wrote me everything I need for the report into a SQL Query and now I'm supposed to format it in CR XII literally do not know what to do from here. I'm able to set up the correct server as a datasource, if that's useful, but I don't know how to make the querey into a bunch of formattable fields in CR. If anyone can walk me through this, I'd be so grateful. I've attempted to look up SQL query in both the help and the book but I keep hitting a wall. The help dialog says things like "press this button" with no reference to what "this button" is. I'm sure it's obvious to the knowledgeable but I'm in a complete fog. Thanks in advancePost Author: synapsevampire
CA Forum: Data Connectivity and SQL
IF you're trying to get assistance with setting up a query as the source for a report, try posting your Crystal version and the database type.
Different software works differently.
In CR 9 and above, under the connection to the database you'll see Add Command. Select that and you can paste the query in.
As for not knowing how to generate a report, that requires experience, there's no generic solution of course..
-k -
Can Portal Report from SQL Query use where column IN (:bind_variable)
I would like to create a portal report from sql query with IN (:bind_variable) in the where clause. The idea is that the user would enter comma-separated or comma-quote-separated values for the bind_variable. I have tried this several ways but nothing seems to work. Can this be done?
TrentonHi,
Which version of portal are you using. This is a bug. It has been fixed in 30984.
Thanks,
Sharmila -
Hi all,
I have data in the following manner:
CASE_NUMBER HOURS FLAG
1000 10 0
1000 20 0
1000 30 1
1000 40 0
1000 50 1
Here I need to Calculate the total hours for a Case_number till i see the flag as 1.
Here the result must be 10+20+30 Hrs
Another Example
CASE_NUMBER HOURS FLAG
2000 10 1
2000 20 1
Here the result must be only 10.
I am struggling to write a SQL query for this.
Anyones help will be very much greatful
Thanks in Advance
Regards,
Sengathir SubbarayanLook up analytical functions.
something like sum(hours) OVER (PARTITION BY case_number ORDER BY something)
will give you the sum for all rows.
Then you probably want to "throw away" those rows after the flag maybe by summing the flag column too, and throw away all those where the flag is greater than 1 and where it is equal to 1 except for the first one.
I suspect you actually have some other column (other than the number of hours) that define your order - that's what you put in the ORDER BY.
Jon
Maybe you are looking for
-
Event handling in abap objects
hello friends, i want to use the event RAISE_LINK_CLICK for single click. but i dont want 2 use this event for alv table. i am displaying vendor name in my top of page,if the user click of the vendor name a new
-
Error -36 while trying to move files on SMB mounted NAS
Hey, I have been experiencing an error -36 while trying to move files around on my NAS. I have the feeling it has something to do with insufficient privileges that are being acquired. When mounting in windows explorer no problems arise. When using th
-
How to give path in Runtime. exec( )
Hi, I am trying to create an user interface, in which, it should open a different file (for example, example.doc)when a button is clicked in the applet. let us say, the path for example.doc is "C:\\WINDOWS\\DeskTOP\\folder1". I tried with the followi
-
Vertical scroll bar disappeared
Vertical scroll bar gone--most annoying when trying to use my google calendar. I read the help responses and couldn't figure out what to do.
-
What is the easiest and preferred method of removing duplicate images from my iPhoto Library? I have a ton of them that occur in many different locations. Also, I need to get rid of all the blurry headshots that iPhoto adds automatically. Thanks