Report in Answers using a SQL Query(Sub Query) URGENT
HI
Can anyone help me in creating a report in answers using this below query please. Its little Urgent. I have no idea how to implement this, please suggest.
Select
a.account_external_id, a.edc_external_id, c.ann_usg, indclassificationcode, g.usage_cv, trunc(g.bill_month, 'mm') bill_month
from
crm2ro.cdi_customer_gas_all a, pwrline.account@lodestar_source b, crm2ro.cdi_ann_usg c,
select * FROM
select * from
select distinct d.account_external_id, d.end_date, d.bill_month, USAGE_CV, dense_rank () over (partition by d.account_external_id order by d.end_Date desc) dr
from
crm2ro.cdi_usage_gas_all d, crm2ro.cdi_customer_gas_all e
where
d.account_external_id = e.account_external_id and upper(e.plan_id) like '%CPS%' and e.product_external_id = 'V' and e.crm_product = 'MV'
and (e.plan_id like '%VAR_CPS_MX_G%' or e.plan_id like '%VAR_CPS_IT_G%') and e.account_status = 'ACTIVE'
)where dr<=12
) h
) g
where
a.account_external_id = g.account_external_id and
a.account_external_id = c.account_external_id and
a.account_external_id = b.accountid
thanks
van
Yes Jai,
I want to do it from rpd or from the advance tab as 974053 said. But I am not aware of doing through advance tab and if I want to do through rpd then how can I do it. Please help me how to build this query through rpd or any other solution.
Similar Messages
-
Using a SQL Query in an Alert and Matching a String
I've created an alert in 12.0.4 using a SQL Query and the field that I'm trying to match is a string. Originally the query returned multiple rows but when the alert still didn't fire, I modified the query WHERE clause to return only one row:
NAME RESPONSE
Are area lights working? No
My expression in the metric is RESPONSE. In the Monitor I'm matching a string equal to No. (Do I need double quotes around the matchvalue? Single quotes? No quotes?) The metric is in the 15min scan group, the role is xMII Developers and I'm in that role. The monitor alert string is ' = '. Both metric and monitor are active and I've subscribed to the monitor. Other alerts in the 15min scan group (all based on tag queries) are firing off properly.
Why is nothing showing up in the Alert Log?
David MacindoeDavid,
Did you figure out the answer? If not, I will try to find someone to address your question.
Mike -
XML Generation using a sql query in an efficient way -Help needed urgently
Hi
I am facing the following issue while generating xml using an sql query. I get the below given table using a query.
CODE ID MARK
==================================
1 4 2331 809
2 4 1772 802
3 4 2331 845
4 5 2331 804
5 5 2331 800
6 5 2210 801
I need to generate the below given xml using a query
<data>
<CODE>4</CODE>
<IDS>
<ID>2331</ID>
<ID>1772</ID>
</IDS>
<MARKS>
<MARK>809</MARK>
<MARK>802</MARK>
<MARK>845</MARK>
</MARKS>
</data>
<data>
<CODE>5</CODE>
<IDS>
<ID>2331</ID>
<ID>2210</ID>
</IDS>
<MARKS>
<MARK>804</MARK>
<MARK>800</MARK>
<MARK>801</MARK>
</MARKS>
</data>
Can anyone help me with some idea to generate the above given CLOB messagenot sure if this is the right way to do it but
/* Formatted on 10/12/2011 12:52:28 PM (QP5 v5.149.1003.31008) */
WITH data AS (SELECT 4 code, 2331 id, 809 mark FROM DUAL
UNION
SELECT 4, 1772, 802 FROM DUAL
UNION
SELECT 4, 2331, 845 FROM DUAL
UNION
SELECT 5, 2331, 804 FROM DUAL
UNION
SELECT 5, 2331, 800 FROM DUAL
UNION
SELECT 5, 2210, 801 FROM DUAL)
SELECT TO_CLOB (
'<DATA>'
|| listagg (xml, '</DATA><DATA>') WITHIN GROUP (ORDER BY xml)
|| '</DATA>')
xml
FROM ( SELECT '<CODE>'
|| code
|| '</CODE><IDS><ID>'
|| LISTAGG (id, '</ID><ID>') WITHIN GROUP (ORDER BY id)
|| '</ID><IDS><MARKS><MARK>'
|| LISTAGG (mark, '</MARK><MARK>') WITHIN GROUP (ORDER BY id)
|| '</MARK></MARKS>'
xml
FROM data
GROUP BY code) -
Can we use Data Pump to export data, using a SQL query, doing a join
Folks,
I have a quick question.
Using Oracle 10g R2 on Solaris 10.
Can Data Pump be used to export data, using a SQL query which is doing a join between 3 tables ?
Thanks,
AshishHello,
No , this is from expdp help=Y
QUERY Predicate clause used to export a subset of a table.
Regards -
How to use this sql query in oracle?
Hi all,
i am using one sql query that is
SELECT @ToDate = '2012-10-03 00:00:00.000'
select @BetweenDate = DATEADD(MM,-1,@ToDate)
select @FromDate = DATEADD(m,DATEDIFF(m,0,@BetweenDate),0)
SELECT @ToDate = DATEADD(month, ((YEAR(@BetweenDate) - 1900) * 12) + MONTH(@BetweenDate), -1)
so @todate value is = '2012-10-03 00:00:00.000'
so in @betweendate value will come 1 month before like '2012-09-03 00:00:00.000'
again in @fromdate value will come like that '2012-09-01 00:00:00.000' means first date of @betweendate
and again @todate value will come like that '2012-09-30 00:00:00.000' means last date of @betweendate
it's happening in sql and i have to use same logic in oracle also.
how to use it??
thanksdeclare
todate date:= to_date('2012-10-03 00:00:00','yyyy-mm-dd hh:mi:ss');
betwendate date := add_months(todate,-1);
for datediff / additions you can direct subtract/add two different date variables
like
datediff = betweendate -todate
dateadd := todate+1; -
Hi,
I want to use the SQL query IF EXIST to update or insert data in a ms access table, but it doesn´t work
(fault number -2147217900)
I want to search for a value in a ms access table , if it exist i want to update it, if not i want to insert a new row.
Working with LabView 7.1, database con. toolset.
Who can HELP?
Thanks a lot
MarcoHello,
I think that If exist is not a standar SQL command (I know it exists I think in Oracle and SQL server), MS access doesn't support it, so I think the best way to do it is first make a Select and then either an Update or an insert, sorry...
Paulo -
Im writing a jsp that pulls data from the database and loads it into dropdown-list looks like this:
<select name="Source">
<%
conn = DriverManager.getConnection(url, username, password);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery("SELECT BBCourseID(Sroffer.SrofferID)course_name, SrofferSchedule_Faculty.FacultyID AS FacultyID FROM SrofferSchedule_Faculty srofs JOIN SrofferScheduleID sros ON srofs.SrofferScheduleID= sro.SrofferScheduleID JOIN Sroffer sro ON sro.SrofferID= sros.SrofferID WHERE srofs.FacultyID=IDnumber");
rs.beforeFirst();
while (rs.next()) {%>
<option value="<%=courseid=rs.getString("BBCourseID")%>"><%=courseid%> <%=rs.getString("course_name")%></option>
<%}
%>
</select>
Problem is, I have to pull the FacultyID from cams using this sql query
("SELECT FacultyID FROM FacultyPortal WHERE PortalAlias="") berfore i can run the query above. Don't know how to do this in a jsp
Edited by: JohnsonJ on Mar 26, 2009 5:53 PMYou know how to get a connection and how to execute a query and how to process the resultset - so what's standing in your way of doing that for the faculty ID?
Isn't there a join you can do to get that in one query?
And finally - you really shouldn't do this in a JSP, use a servlet to package the result up in some Java Collection and process it with JSTL tags. -
Creating Crystal Reports Dynamically from an incoming SQL query
Hi,
I have a requirement where a sql query will be entered by the user in a text box and in the back end java code, i have to create a crystal report dynamically based on that sql query and show it in the crystalviewer object.
For example if the user writes "select x,y from xtable ", i should be able to create a report with 2 fields, and if the user says "select x,y,z from xtable" then i should be able create and show a report with 3 fileds...thsi report creation should be done in the click event.
Is this possible in java? I have found something similar in .NET... pls have a look at this
http://vb.net-informations.com/crystal-report/dynamic_crystal_report_from_sql_query_string.htm
Thanks,
PreethiHi Preethi,
Can you please share the steps with me? I am also looking for dynamic SQL being applied to the crystal report.
Thank you so much for your help in advance.
Regards,
Janakiram D. -
APEX validations in updateable reports built on a PL/SQL query
Sorry if the question is not clear (english is not my mother language) or if the answer already exists on the forum (I have not been able to find it).
I build a report on a PL/SQL function query.
In this PL/SQL query i use apex_item.checkboxes or texts to let the end user change/enter some new data.
As i need to do some validations on the user entries, i have already used some events (e.g. onChange) that trigger
simple javascript validations checking if data is numeric or length of data entered....
But i would like to use also the standard validations of APEX to make some more complex validations (e.g. checking coherency) on
many data entered by the end user.
I am trying to build a PL/SQL to loop through the report lines through a checkbox item i have added
but the process of debugging is awfull for me.
- Is there a pointer to a code example of validations within a query report that would help me in achieving this validation
- or could someone give me some clue on how to acess these report data in the interface.
Thanks in advance,
DanielDaniel:
You can check out Denes Kubicek's APEX demo site for ideas on how to create validations for a tabular form.
http://htmldb.oracle.com/pls/otn/f?p=31517:41:3322496527336906:::RP,::
Varad -
Discoverer Report showing Null VS Show SQL query showing results !!!
I created a simple Cross Tab Discoverer report from a custom SQL which has a calculation for balances. The output is giving all null values even though there are balances. The output doesn't seem right. So I copied the query from Tools-->Show SQL and ran the query in the TOAD where I'm showing balances for the report. I don't understand why it is not showing in the discoverer. Please help.
Thanks
Edited by: PA1B on Jan 27, 2010 11:40 AMSorry for late reply.
Below is the Show SQL query. I don't think the query is application dependent. C_1 is my calculation.
SELECT o279709.SEGMENT3 as E279727,
o279709.SEGMENT4 as E279728,
CASE WHEN o279709.CURRENCY_CODE = 'USD' AND o279709.TRANSLATED_FLAG <> 'Y' THEN SUM(o279709.ENDING_BAL) ELSE 0 END as C_1,
GROUPING_ID(o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG) as GID
FROM ( --Foriegn Entity USD Balances
SELECT B.SEGMENT1,
B.SEGMENT2,
B.SEGMENT3,
(select distinct substr(cat.COMPILED_VALUE_ATTRIBUTES,5,1) from apps.fnd_flex_values cat
where FLEX_VALUE_SET_ID = (select bat.FLEX_VALUE_SET_ID from apps.fnd_id_flex_structures_vl aat, apps.fnd_id_flex_segments_vl bat
where bat.id_flex_code = 'GL#' and
bat.id_flex_code = aat.id_flex_code and
aat.APPLICATION_ID = bat.APPLICATION_ID and
aat.APPLICATION_ID = 101 and
bat.SEGMENT_NAME = 'Prime Account' and
aat.id_flex_num = bat.id_flex_num
and bat.id_flex_num in (select distinct chart_of_accounts_id from apps.gl_code_combinations gat
where gat.code_combination_id = A.code_combination_id))
and cat.flex_value = b.segment3) ACCT_TYPE ,
B.SEGMENT4,
B.SEGMENT5,
B.SEGMENT6,
B.SEGMENT7,
B.SEGMENT8,
B.SEGMENT9,
B.SEGMENT10,
B.SEGMENT11,
B.SEGMENT12,
B.SEGMENT13,
C.NAME,
A.SET_OF_BOOKS_ID,
A.CURRENCY_CODE,A.TRANSLATED_FLAG,
SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0)) BEG_BAL,
SUM(NVL(A.PERIOD_NET_DR,0)) DEBITS,
SUM( NVL(A.PERIOD_NET_CR,0)) CREDITS ,
A.PERIOD_NAME,
SUM(NVL(A.BEGIN_BALANCE_DR,0) - NVL(A.BEGIN_BALANCE_CR,0))+ SUM(NVL(A.PERIOD_NET_DR,0) - NVL(A.PERIOD_NET_CR,0)) ENDING_BAL
FROM APPS.GL_BALANCES A ,
APPS.GL_CODE_COMBINATIONS B,
APPS.GL_SETS_OF_BOOKS C
WHERE A.CODE_COMBINATION_ID = B.CODE_COMBINATION_ID
--AND A.PERIOD_NAME = 'SEP-09'
AND C.SET_OF_BOOKS_ID = A.SET_OF_BOOKS_ID
--AND A.TRANSLATED_FLAG <> 'Y'
--AND B.SEGMENT1 = '83101'
--AND B.SEGMENT3 = '14602'
--AND A.SET_OF_BOOKS_ID = 77
--AND A.CURRENCY_CODE = 'USD'
GROUP BY A.CODE_COMBINATION_ID,
B.SEGMENT1,
B.SEGMENT2,
B.SEGMENT3,
B.SEGMENT4,
B.SEGMENT5,
B.SEGMENT6,
B.SEGMENT7,
B.SEGMENT8,
B.SEGMENT9,
B.SEGMENT10,
B.SEGMENT11,
B.SEGMENT12,
B.SEGMENT13,
A.CURRENCY_CODE,
A.TRANSLATED_FLAG,
C.NAME,A.PERIOD_NAME,
A.SET_OF_BOOKS_ID
) o279709
WHERE (o279709.PERIOD_NAME = 'DEC-09')
AND (o279709.SET_OF_BOOKS_ID <> 72)
AND (o279709.SEGMENT12 = '000')
AND (o279709.SEGMENT3 IN ('10101','10301','10502','12001'))
AND (o279709.SEGMENT1 IN ('82901','82902','82903','83001','83003','83201'))
GROUP BY GROUPING SETS(( o279709.CURRENCY_CODE,o279709.SEGMENT3,o279709.SEGMENT4,o279709.TRANSLATED_FLAG ),( o279709.SEGMENT3,o279709.SEGMENT4 ),( o279709.SEGMENT3 ))
HAVING (GROUP_ID()=0)
ORDER BY GID DESC;
Thanks,
PA1
Edited by: PA1B on Jan 29, 2010 12:50 PM -
Is there a way to consolidate calculations used in SQL Query Data Sets?
I am building SQL Query Data Sets against multiple DB Views which all have different date formats. I have the date parameter working well, but want to consolidate the changes that I have to do to it especially for the quarter. For example the SQL against a monthly view would use "where year_month > to_char(:ST_DATE, 'YYYY-MM')" which is not too hard, but to make that work for the quarterly view I need several concats and a decode to get a "> '2012-Q2'". I would like not to have to do this within every where clause. I had put this into a global element hoping to use that in a filter for the data set, but the filter does not have access to global elements only parameters.
Is there any way to refer to a calculated global element from the data set to do this? I am using Layout Templates, so even if I wanted to I could not do the condition within the template.
Thanks,
RickChange the following line to include the red coloured parts
<div class="MasterColumn" spry:repeat="ds4" spry:setrow="ds4" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected">
<span>{Dsp_#}</span><span>{Dsp_WkDay}</span><span>{Dsp_Event}</span>
</div>
The add the following style rule to your document:
.MasterColumn span {
display: inline-block;
I hope this helps.
Ben -
Use an SQL Query in a backing bean
hi,
I like to know how to run an SQL query in a backing bean method, this being the code I tried , his goal is to fill the field "cin" with data coming from my database, here is the Code:
public String cb2_action() {
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("CreateInsert");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
DCIteratorBinding dciter =(DCIteratorBinding) bindings.get("PersonneView1Iterator");
Row row=dciter.getCurrentRow();
Statement stmt = this.getDBTransaction().createStatement(1);
try {
ResultSet rs = stmt.executeQuery("select max(cin) from personne");
while( rs.next() ){
row.setAttribute("cin", rs.getInt(1)+1);
} catch (SQLException ex) {
ex.printStackTrace();
return "go";
at run time it give an error at this line : Statement stmt = this.getDBTransaction().createStatement(1);
please check and correct me
thanks in advanceHi,
Initially I would like to say that this should not be used if you are trying to get a PrimaryKey as it would cause serious concurrency issues.
For example lets say that you want whenever you create a new Employee to set his DepartmentId equal to the max department.
We could create a readOnly VO (lets name it MaxDepartmentId) with a query that returns the max departmentId:
select max(Department_Id) as maxDep from DepartmentsAfter that we need to add the MaxDepartmentId VO as a ViewAccessor in our Employees Vo,
override the create() method in the EmployeesRowImpl and add some code like this:
public class EmployeesRowImpl extends ViewRowImpl {
@Override
protected void create(AttributeList attributeList) {
Row r=getMaxDepartmentId().first();
if(r!=null){
Number max=(Number)r.getAttribute("Maxdep");
attributeList.setAttribute("DepartmentId", max);
super.create(attributeList);
}That's all.
If you run this you will see that when you create a new employee it has a default value.
Gabriel. -
Check the hints used in SQL Query (Parallel, First_Rows)
Hi,
I have used above hints in my sql query and found no difference in execution time.
I just want to know whether the hints are used in my sql are not.
Could you please let me know where to check for it.
Thanks in advanceCan you post the SQL which uses these hints and the execution plan with and without those hints here? Then only community can help you find out if the hints are really used or not.
Please use code tags to preserve the format of execution plan.
Edited by: Satish Kandi on Jun 23, 2009 5:37 PM -
How to create a Folder using a SQL Query?
Hi
How can I create a Folder (eg. C:\MyNewFolder) using SQL Query?Hi,
I added some code in order to get the result from the xp_cmdshell command
This returns null if successfull, if an error occurs returns the error message. May be useful instead of getting an sql error
Code Snippet
declare @cmdpath nvarchar(60), @Location nvarchar(100), @message nvarchar(max)
set @Location = N'C:\Temp\Temp5'
set @cmdpath = 'MD '+ @Location
Create table #result
result nvarchar(255)
insert into #result (result) exec master.dbo.xp_cmdshell @cmdpath
select @message = ISNULL(@message + ' - ','') + result from #result where result is not null
select @message
drop table #result
Eralper
http://www.kodyaz.com -
Crystal Reports 10 Datasource Location and SQL Query update
I am running Crystal Reports 10 accessing SQL Server 2008 database on Windows 7. Our product changed database names and I'm trying to update reports to point to the new database. Sounds nice and simple. The database has no structure changes yet, it's just a copy and rename of the old database. Both databases exist, same SQL instance, same permissions, etc. ...
Existing working report:
Has an ODBC (RDO) location to database DbVersion1
If I run Show SQL Query, the database name is in the query text (i.e. FROM DbVersion1.dbo.MyTable)
Attempted:
In Set Database Location popup, I created a new ODBC (RDO) connection to database DbVersion2
Updated Current Data Source for report to this new ODBC (RDO) connection.
Ran Verify Database. Popup stated "The database is up to date."
But when I run "Show SQL Query", is still shows DbVersion1 in the text, and the report displays data from DbVerison1. When I display the Datasource Location for the report, it shows DbVersion2 as I changed to above. How do I "refresh" the SQL Query to recognize the new Datasource Location?
Thanks,
GaryHi Gary,
A possible couple of issues, CR 10 doesn't support SQL Server 2008 and it doesn't support Windows 7. We had to update CR XI R2 SP 6 and above to make SQL 2008 work. MS changed the name of their client dll so CR is not aware of the new drivers.
MDAC native driver may work but not sure....
Try OLE DB, it may work better.
Thanks
Don
Maybe you are looking for
-
Printer Queue Settings Mysteriously Reverting Back to Default Settings on 2008 R2 print servers
Printer Queue Settings Mysteriously Reverting Back to Default Settings on 2008 R2 print servers We have 4 Windows Server 2008 R2 print servers, all of which has the same printer queues installed on them that are utilized by a 3rd party printing progr
-
today i want to purchase either an i mac or macbook pro. please help me to choose one. my main interest is to work with photos. if mac book pro is capable of dealing with high end software like adobe photoshop cs6, is it preferrable to buy it or shou
-
I've lost all my contacts and calendars on my phone. How do I get it back again?
I've lost all my contacts and calendars on my iphone 4s. How do I get it back again?
-
In FF 4.0 why does the down arrow no longer function in the vertical scroll bar?
Prior to FF 4.0 when I positioned my cursor over the down arrow of the vertical scroll bar in Hotmail and depressed the left mouse button, the scroll bar moved downward toward the bottom of it's column limit. Now in 4.0 it turns into an adjustment cu
-
Both my consultant and myself use Reader X1 to print pdf files made in 995. When he prints the pdf file that come out ok but when I try to print the same pdf it comes out light. Does anyone have any suggestions as to what may be causing this or how t