TIMESTAMPADD query filter (8 weeks)
Hi guys,.I can use some wisdom here on best practices to predefine a report to retrieve data for the last 8 weeks. Ideally, this will be the last week of business completed in 8 weeks. Below, is what I've gathered so far which is really Basic. Currently, when I run the report he pulls the current week 8 weeks old.
The filter is applied as a filter of column slot, and the filtered field is [week], in the case where it makes a difference.
TIMESTAMPADD (SQL_TSI_WEEK-8, (CURRENT_DATE))
Another scenario, if possible, I'm looking for a way to recover the last 8 weeks, but instead should begin two weeks of the current week, and then 8 weeks back. Our SLA for some records takes a full two weeks to determine if the ALS will be achieved or missed.
Example: If I ran the report today, I expect to recover data from 8 weeks two weeks from the current week, such as 2/21 today and the current = 18/02/13 week recovered weeks would be following weeks 24/12/12 to 04/02/2013
All suggestions greatly appreciated ~!
Can update you this post with the right answer?
I would like to know it. I know how complex it is ;)
Published by: Srini VIEREN on February 22, 2013 14:23
Tags: Business Intelligence
Similar Questions
-
Hello
I wrote a query to get a weekly report, which is expected to start a week from Sunday to Saturday typical. for example, the week is 03/04/2011 to 04/09/2011 I run the query or the task on Word to say about any of the week of 10/04/2011, 04.11.2011 etc... Here's my query, but it seems to work of the sysdate to-7 days that does not receive the Sunday to Sam requirement... someone can you please...
Select uid, psn, TO_char(date_in,'mm/dd/yyyy')
OF THE TEST
WHERE the uid like '% % ST.
and date_in > trunc (sysdate)-7
ORDER BY date_in CSA;
Thank you.If you want that data for the week previous ? In if so then just tweak the settings a bit:
SELECT uid , psn , TO_char(date_in,'mm/dd/yyyy') FROM test WHERE uid LIKE '%ST%' AND date_in >= TRUNC(SYSDATE,'IW') - 8 AND date_in < TRUNC(SYSDATE,'IW') - 1 ORDER BY date_in ASC ;
-
ADFBC-ADF Faces: slow query filter
Hi community, I have a VO maped with a larger table, this VO is filter with setwhereclause, query works fine but it is too slow in all consultations.
I'm really confused tried everything but the request is still very slow.
Thanks Comunity.Hi Peter, I have a solution to your problem, when you perform a filter with a method in the ViewObject implementation with this.setWhereClause (); Positional JDBC and consultation is built as follows:
SELECT * FROM (ORIGIN REQUEST VO) WHERE (YOUR CUSTOM FILTER)
This type of filter produces a query of doble reprocessing, in tables with many registers reduces the performance and speed of the query.
Try to use filters with viewCriterias, check your Oracle named binding style and use filter like that in your VO implementation:
//----
ViewCriteria vc = this.createViewCriteria ();
Vcr1 ViewCriteriaRow = vc.createViewCriteriaRow ();
VCR1.SetAttribute ("COD", "MyValue");
VC. Add (VCR1);
this.applyViewCriteria (vc);
this.executeQuery ();//----
More information [http://download-west.oracle.com/docs/cd/B32110_01/web.1013/b25947/bcquerying.htm#BCGIFHHF]
Good luck.
-
A query with the weeks/months/quarters without filling data
During recovery of monthly data from any data source, experts how CF (which I am not one) creates results for the time intervals where there is no results? I.E. event data to draw per month, how can I show that there can be no activity for a given month? Thanks in advance.There is a way to make more efficient approach to dempster.
Step 1: run your query from the database. (1 queries)
Step 2 - create a cold fusion query to get all years-months in the range of dates of interest (2 requests)
Step 3 - make a query of queries for years-monthly query 2 that are not in the application 1. (3 requests)
Step 4: make a query of queries that questions 1 and 3 trade unions. -
query to get week number Pls help
I need to get the number of the week of the current year in the format 2008-W47 (this applies to sysdate
When I try
Select to_CHAR (sysdate, 'YYYY' |'-IW')
OF THE DOUBLE
I get 2008-47
but in the format 2008-W47
Help
sSQL> select to_CHAR(sysdate,'YYYY')||'-W'||to_char(sysdate,'IW') from dual 2 / TO_CHAR( -------- 2008-W47
-
SO I created a combination of research and results page which works very well. In the database, I have a Boolean variable that determines if the record is active. I want to include a check box on the search form that returns only active records. A little hard. Here is the code:
<? php require_once('Connections/testmypms.php');? >
<? PHP
$currentPage = $_SERVER ['PHP_SELF'];
$maxRows_demographics = 10;
$pageNum_demographics = 0;
If (isset($_GET['pageNum_demographics'])) {}
$pageNum_demographics = $_GET ['pageNum_demographics'];
}
$startRow_demographics = $pageNum_demographics * $maxRows_demographics;
$vardemid_demographics = '% ';
If (isset($_POST['schDemID'])) {}
$vardemid_demographics = (get_magic_quotes_gpc())? $_POST ['schDemID']: addslashes($_POST['schDemID']);
}
$vardemfirstname_demographics = '% ';
If (isset($_POST['schDemFirstname'])) {}
$vardemfirstname_demographics = (get_magic_quotes_gpc())? $_POST ['schDemFirstname']: addslashes($_POST['schDemFirstname']);
}
$vardemsurname_demographics = '% ';
If (isset($_POST['schDemSurname'])) {}
$vardemsurname_demographics = (get_magic_quotes_gpc())? $_POST ['schDemSurname']: addslashes($_POST['schDemSurname']);
}
$vardemactive_demographics = "1";
If (isset($_POST['schActive'])) {}
$vardemactive_demographics = (get_magic_quotes_gpc())? $_POST ['schActive']: addslashes($_POST['schActive']);
}
@mysql_select_db ($database_testmypms, $testmypms);
$query_demographics = sprintf ("SELECT demographics.px_id, demographics.firstname, demographics.surname, demographics.address1, demographics.address2, demographics.town, demographics.postcode, title.title, demographics.active FROM demographics, title demographics WHERE.") ("FK_title_id = title.title_id AND demographics.px_id AS ' %s %' AND demographics.firstname AS ' %s %% ' AND demographics.surname AS ' %s %' ORDER BY demographics.surname an AND demographics.active='%s, demographics.firstname ', $vardemid_demographics, $vardemfirstname_demographics, $vardemsurname_demographics, $vardema ctive_demographics);
$query_limit_demographics = sprintf ("%s LIMIT %d, %d", $query_demographics, $startRow_demographics, $maxRows_demographics);
$demographics = mysql_query ($query_limit_demographics, $testmypms) or die (mysql_error ());
$row_demographics = mysql_fetch_assoc ($demographics);
If (isset($_GET['totalRows_demographics'])) {}
$totalRows_demographics = $_GET ['totalRows_demographics'];
} else {}
$all_demographics = mysql_query ($query_demographics);
$totalRows_demographics = mysql_num_rows ($all_demographics);
}
$totalPages_demographics = ceil($totalRows_demographics/$maxRows_demographics)-1;
$queryString_demographics = "";
If (! empty($_SERVER['QUERY_STRING'])) {}
$params = explode ("&", $_SERVER ['QUERY_STRING']);
$newParams = array();
{foreach ($params as $param)
If (stristr ($param, "pageNum_demographics") == false & &)
stristr ($param, "totalRows_demographics") == false) {}
return ($newParams, $param);
}
}
If (count ($newParams)! = 0) {}
$queryString_demographics = '& '. htmlentities (implode ("&", $newParams));
}
}
$queryString_demographics = sprintf ("& totalRows_demographics = %d %s", $totalRows_demographics, $queryString_demographics);
? >
< ! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional / / IN" "http://www.w3.org/TR/html4/loose.dtd" > ""
< html >
< head >
< meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 ">"
< title > Search < /title >
< / head >
< body >
Search Patient < p > < /p >
< do action = "" method = "post" name = "schDem" id = "schDem" > "
< table border = "1" cellspacing = "1" cellpadding = "5" >
< b >
ID < td > < table >
< td > < input name = "schDemID" type = 'text' id = 'schDemID' > < table >
< td > < table >
< /tr >
< b >
FirstName < td > < table >
< td > < input name = "schDemFirstname" type = 'text' id = 'schDemFirstname' > < table >
< td > < table >
< /tr >
< b >
last name < td > < table >
< td > < input name = "schDemSurname" type = 'text' id = 'schDemSurname' > < table >
< td > assets show only
< input name = "schActive" type = "checkbox" id = "schActive" value = "0" checked > < table >
< /tr >
< b >
< td > < table >
< td > < input name = "Search" type = "submit" id = "Search" value = "Search" > < table >
< td > < table >
< /tr >
< /table >
< / make >
< p > < a href = "<?" PHP printf ("%s? (pageNum_demographics = %d %s", $currentPage, max (0, $pageNum_demographics - 1), $queryString_demographics);? > "> previous < /a > < a href =" <? PHP printf ("%s? (pageNum_demographics = %d %s", $currentPage, min ($totalPages_demographics, $pageNum_demographics + 1), $queryString_demographics);? > "> Next < /a > < /p >"
< table border = "1" >
< b >
px_id < td > < table >
title < td > < table >
FirstName < td > < table >
last name < td > < table >
address1 < td > < table >
address2 < td > < table >
< td > city < table >
< Td > < table > zip code
< /tr >
<? PHP {? >}
< b >
< td > < a href = "main.php? pxID = <?" PHP echo $row_demographics ["px_id"];? > "> <?" PHP echo $row_demographics ["px_id"];? > < /a > < table >
< td > <? PHP echo $row_demographics ['title'];? > < table >
< td > <? PHP echo $row_demographics ["FirstName"];? > < table >
< td > <? PHP echo $row_demographics ['name'];? > < table >
< td > <? PHP echo $row_demographics ['Address1'];? > < table >
< td > <? PHP echo $row_demographics ["address2"];? > < table >
< td > <? PHP echo $row_demographics ['city'];? > < table >
< td > <? PHP echo $row_demographics ['postal code'];? > < table >
< /tr >
<? PHP} while ($row_demographics = mysql_fetch_assoc ($demographics));? >
< /table >
< / body >
< / html >
<? PHP
mysql_free_result ($Demographics);
? >
Any suggestion would be great
Thank you
This is because your logic is reversed. You should show the default value of 0 (zero) and then a value of 1 if it is defined. Try this
$vardemactive_demographics = 0;
If (isset($_POST['schActive'])) {}
$vardemactive_demographics = 1;
}
-
column headers dynamically change the date filter-based selection? in obiee 11g Analytics
Hello
I work an analytic of obiee 11g.
I have my report coulmns five... who are the branch, district, DS, current year, the previous year.
based on the article on the query filter, column headings change dynamically.
column headings are current, previous year Yes r;
current month, previous month;
current week and the previous week.
for example, if I select the year 2016.
column headings are Branch, district, DS, 2016, 2015 will change dynamically in the analytical report...
Please help me,
I tried, but I do not have...
Please help me,
A.Kavya.
I'm not really sure what you have, but assuming that you have a command prompt of dashboard with the year of the column, define a variable presentation for this column (pv_year) and then in the report, for the columns you want, set the column as header @{pv_year} and @{pv_year-1}.
He must pick up the values from the command prompt and dynamically set in the column headers.
-
Hallo,
I would like to know if it is possible to change the criteria for the view or the query used by an LOV entry before the opening of the pop-up window (on the click the icon in the search).
Thank you
Federico
You can change the implicit vc used by the LOV, overwriting the popuplistener and a different VC as
{} public void onLauchLov (LaunchPopupEvent launchPopupEvent)
String submittedValue = (String) launchPopupEvent.getSubmittedValue ();
run the queries only if value is submitted
If (submittedValue! = null & submittedValue.length () > 0) {}
RichInputListOfValues lovComp = launchPopupEvent.getComponent ((RichInputListOfValues));
BindingContext bindingCtx = BindingContext.getCurrent ();
BindingContainer links = bindingCtx.getCurrentBindingsEntry ();
JUCtrlListBinding lov = bindings.get ("JobId") (JUCtrlListBinding);
VCM ViewCriteriaManager = lov.getListIterBinding () .getViewObject () .getViewCriteriaManager ();
ensure that the criteria of display is disabled
vcm.removeViewCriteria (ViewCriteriaManager.IMPLICIT_VIEW_CRITERIA_NAME);
Create a new view of the criteria of
ViewCriteria vc = new ViewCriteria (lov.getListIterBinding () .getViewObject ());
Use the name of the default view criteria
'__DefaultViewCriteria__ '.
vc.setName (ViewCriteriaManager.IMPLICIT_VIEW_CRITERIA_NAME);
create a display for all queryable attributes criteria
VCR ViewCriteriaRow = new ViewCriteriaRow (vc);
for this example, I put the query filter for 60 DepartmentId.
You can determine when running in reading to a managed bean
or the link layer
vcr.setAttribute ("JobId", submittedValue + "%");
Note also that the line of view criteria consists of all attributes
who belong to the view list LOV object, which means that you can
filter on multiple attributes
vc.addRow (vcr);
lov.getListIterBinding () .getViewObject () .applyViewCriteria (vc);
}
}
Here's the LOV on the employee on the work of attribte based on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/29-adf-model-driven-llist-of-values-169171.pdf
Timo
-
How to query a single partition of a table
Dear Experts,
Please, help me in this issue.
https://community.Oracle.com/thread/3511578
I try to get the number of records in a partition of a table. 11.2.0 Oracle database version
Picture is of size 700 GB.
Table is partitioned on COVERED_LINE_END_DATE using the range.
I want my query to run on particular partition
I created the local partition on COVERED_LINE_END_DATE index
I want to restrict my questions to a single partition, and then I want to use index to get quick results.
Currently my queries takes hours, and same table without partition table works well.
Please suggest me how this partition table.
I always ask this table by using the range of dates, which is quarterly.
so I partiton table quarterly. and then I want to index particular partition.
PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- SQL_ID a75mjmfsd873v -------------------- select count(1) FROM X_3_PV_TD_LINE_ITEMS_FF_REL_2 A WHERE A.COVERAGE = 'COVERED' AND A.SERIALIZED = 'Y' AND A.COVERED_LINE_END_DATE BETWEEN sysdate-30 AND sysdate Plan hash value: 3089225921 ------ | Id | Operation | Name| Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | TQ |IN-OUT| PQ Distrib | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT || | | 1425 (100)| | | | | | | | 1 | SORT AGGREGATE || 1 | 21 | | | | | | | | | 2 | PX COORDINATOR || | | | | | | | | | | 3 | PX SEND QC (RANDOM) | :TQ10000| 1 | 21 | | | | | Q1,00 | P->S | QC (RAND) | | 4 | SORT AGGREGATE || 1 | 21 | | | | | Q1,00 | PCWP | | | 5 | FILTER || | | | | | | Q1,00 | PCWC | | | 6 | PX PARTITION LIST ALL || 1307 | 27447 | 1425 (1)| 00:00:18 | 1 | 5 | Q1,00 | PCWC | | | 7 | TABLE ACCESS BY LOCAL INDEX ROWID| X_3_PV_TD_LINE_ITEMS_FF_REL_2| 1307 | 27447 | 1425 (1)| 00:00:18 | KEY | KEY | Q1,00 | PCWP | | | 8 | INDEX RANGE SCAN | X_3_COVERED_LINE_END_DATE_IDX| 5229 | | 209 (0)| 00:00:03 | KEY | KEY | Q1,00 | PCWP | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 22 rows selected.
Thanks in advance for your help and your time.
Thus, a query today in February will span two partitions FY14Q3 and FY14Q2 * and * actually access all subparts in each of these two partitions because your query filter to a specific subpartition.
Hemant K Collette
-
Hello
It's my first table REPORT
report as)
Select 'vendor_1' vendor, to_date('1/1/2012','DD/MM/YYYY') supply_date, "customer_1" as a customer, "item_1" like item1, 110 as cost of double union all
Select 'vendor_1' vendor, to_date('1/3/2012','MM/DD/YYYY') supply_date, "customer_1" as a customer, "item_1" like item1, 120 as cost of double union all
Select 'vendor_1' vendor, to_date('1/3/2012','MM/DD/YYYY') supply_date, "customer_1" as a customer, "item_1" like item1, 130 as cost of double union all
Select 'vendor_1' vendor, to_date('1/4/2012','MM/DD/YYYY') supply_date, "customer_1" as a customer, "item_1" like item1, 140 as cost of double union all
Select 'vendor_1' vendor, to_date('1/10/2012','MM/DD/YYYY') supply_date, "customer_1" as a customer, "item_1" element, 200as cost of double union all
Select 'vendor_1' vendor, to_date('1/23/2012','MM/DD/YYYY') supply_date, "customer_1" as a customer, "item_1" as point 0 as the cost of dual union all
Select 'vendor_1' vendor, to_date('1/6/2012','MM/DD/YYYY') supply_date, "customer_2" as a customer, "item_1" like item1, 160 as cost of double union all
Select 'vendor_1' vendor, to_date('1/7/2012','MM/DD/YYYY') supply_date, "customer_2" as a customer, "item_1" like item1, 170 as cost of double union all
Select 'vendor_1' vendor, to_date('1/8/2012','MM/DD/YYYY') supply_date, "customer_2" as a customer, "item_1" like item1, 180 as cost of double union all
Select 'vendor_1' vendor, to_date('1/9/2012','MM/DD/YYYY') supply_date, "customer_2" as a customer, "item_1" like item1, 190 as cost of double union all
Select 'vendor_1' vendor, to_date('1/20/2012','MM/DD/YYYY') supply_date, "customer_2" as a customer, "item_1" like item1, 300 as cost of double)
IT'S MY SECOND TABLE: TEMP_WEEK
WITH temp_week (s)
SELECT January 1, 2012 to 07/01/2012 ' AS the week of all the double union
SELECT August 1, 2012 to 14/01/2012 ' AS the week of all the double union
January 15, 2012 to 21/01/2012 ' AS the week of all the double union
SELECT January 22, 2012 to 28/01/2012 ' AS the week of all the double union
(SELECT 29 January 2012 to 31/01/2012 ' WEEK of double)
To find weekly sales that I wrote query below:
SELECT week, supplier, customer, SUM (cost)
(SELECT week, supplier, customer, TOTAL costs (cost)
FROM (SELECT BOX
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 1 AND 7 MAY
January 1, 2012 to 07/01/2012 '
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 8 AND 14 MAY
14/01/2012, 1 August 2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 15 AND 21 THEN
January 15, 2012 to 21/01/2012 '
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 22 AND 28 and THEN
January 22, 2012 to 28/01/2012 '
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 29 AND 31 MAY
29 January 2012 to 31/01/2012 '
END
week, supplier, customer, cost
REPORT)
GROUP BY week, supplier, customer
UNION ALL
SELECT tw.week, vendor, customer or 0
(SELECT week, supplier, customer, TOTAL costs (cost)
FROM (SELECT BOX
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 1 AND 7 MAY
January 1, 2012 to 07/01/2012 '
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 8 AND 14 MAY
14/01/2012, 1 August 2012'
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 15 AND 21 THEN
January 15, 2012 to 21/01/2012 '
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 22 AND 28 and THEN
January 22, 2012 to 28/01/2012 '
WHEN TO_NUMBER (TO_CHAR (TRUNC (supply_date), 'DD')) BETWEEN 29 AND 31 MAY
29 January 2012 to 31/01/2012 '
END
week, supplier, customer, cost
REPORT)
GROUP BY week, supplier, customer), temp_week tw)
GROUP BY week, supplier, customer
ORDER BY supplier, customer, week;
with above query I get below output:
with output voltage)
Select January 1, 2012 to 07/01/2012 ' week, 'vendor_1' as a provider, "customer_1" as a customer, 500 as cost of double union all
Select August 1, 2012, to 14/01/2012 ' week, 'vendor_1' as a provider, "customer_1" as a customer, 200 as cost of double union all
Select January 15, 2012 to 21/01/2012 ' week, 'vendor_1' as a provider, "customer_1" as a customer, 0 as the cost of dual union all
Select January 22, 2012 to 28/01/2012 ' week, 'vendor_1' as a provider, "customer_1" as a customer, 0 as the cost of dual union all
Select the 29 January 2012 to 31/01/2012 ' week, 'vendor_1' as a provider, "customer_1" as a customer, 0 as the cost of dual union all
Select January 1, 2012 to 07/01/2012 ' week, 'vendor_1' as a provider, "customer_2" as a customer, 330 as costs of double union all
Select August 1, 2012, to 14/01/2012 ' week, 'vendor_1' as a provider, "customer_2" as a customer, 370 as cost of double union all
Select January 15, 2012 to 21/01/2012 ' week, 'vendor_1' as a provider, "customer_2" as a customer, 300 as cost of double union all
Select January 22, 2012 to 28/01/2012 ' week, 'vendor_1' as a provider, "customer_2" as a customer, 0 as the cost of dual union all
Select the 29 January 2012 to 31/01/2012 ' week, 'vendor_1' as a provider, "customer_2" as a customer, double cost of 0)
Clearly, I used cross join. But I want to get the same result with another way. I don't want to use cross join and Union
Please help me in this.What you desire can be accomplished using the outer join partitioned.
The documentation shows an example of [url http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2177515] this way to fill the gaps in the data.Here's how you can use it in your case:
SQL> with report as ( 2 select 'vendor_1' as vendor,to_date('1/1/2012','DD/MM/YYYY') supply_date, 'customer_1'as customer,'item_1' as item1, 110 as cost from dual union all 3 select 'vendor_1' as vendor,to_date('1/3/2012','MM/DD/YYYY') supply_date,'customer_1'as customer, 'item_1' as item1,120 as c ost from dual union all 4 select 'vendor_1' as vendor,to_date('1/3/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item1,130 as cost from dual union all 5 select 'vendor_1' as vendor,to_date('1/4/2012','MM/DD/YYYY') supply_date,'customer_1'as customer, 'item_1' as item1,140 as c ost from dual union all 6 select 'vendor_1' as vendor,to_date('1/10/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item ,200as cost from dual union all 7 select 'vendor_1' as vendor,to_date('1/23/2012','MM/DD/YYYY') supply_date, 'customer_1'as customer, 'item_1' as item,0 as co st from dual union all 8 select 'vendor_1' as vendor,to_date('1/6/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,160 as c ost from dual union all 9 select 'vendor_1' as vendor,to_date('1/7/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,170 as c ost from dual union all 10 select 'vendor_1' as vendor,to_date('1/8/2012','MM/DD/YYYY') supply_date,'customer_2'as customer, 'item_1' as item1,180 as c ost from dual union all 11 select 'vendor_1' as vendor,to_date('1/9/2012','MM/DD/YYYY') supply_date,'customer_2'as customer,'item_1' as item1,190 as co st from dual union all 12 select 'vendor_1' as vendor,to_date('1/20/2012','MM/DD/YYYY') supply_date,'customer_2'as customer,'item_1' as item1,300 as c ost from dual 13 ), weeks as ( 14 select to_date('1/1/2012','DD/MM/YYYY') + (level-1)*7 week_start 15 , to_date('1/1/2012','DD/MM/YYYY') + (level-1)*7 + 6 week_end 16 , level week_pseudo_id 17 from dual 18 connect by level <= 5 /* substitute desired number of weeks */ 19 ) 20 -- 21 -- end-of-test-data 22 -- 23 select to_char(max(weeks.week_start),'DD/MM/YYYY') 24 || ' to ' || 25 to_char(max(weeks.week_end),'DD/MM/YYYY') week 26 , vendor 27 , customer 28 , nvl(sum(cost),0) cost 29 from report 30 partition by (vendor, customer) 31 right outer join weeks 32 on weeks.week_start <= report.supply_date 33 and weeks.week_end >= report.supply_date 34 group by 35 vendor 36 , customer 37 , week_pseudo_id 38 order by 39 vendor 40 , customer 41 , week_pseudo_id 42 / WEEK VENDOR CUSTOMER COST ------------------------ -------- ---------- ---------- 01/01/2012 to 07/01/2012 vendor_1 customer_1 500 08/01/2012 to 14/01/2012 vendor_1 customer_1 200 15/01/2012 to 21/01/2012 vendor_1 customer_1 0 22/01/2012 to 28/01/2012 vendor_1 customer_1 0 29/01/2012 to 04/02/2012 vendor_1 customer_1 0 01/01/2012 to 07/01/2012 vendor_1 customer_2 330 08/01/2012 to 14/01/2012 vendor_1 customer_2 370 15/01/2012 to 21/01/2012 vendor_1 customer_2 300 22/01/2012 to 28/01/2012 vendor_1 customer_2 0 29/01/2012 to 04/02/2012 vendor_1 customer_2 0 10 rows selected.
I have redesigned weeks of date columns for the join which will probably perform better and can possibly use indexes.
I assume that you have no time portion in your supply_date data? If you do, then week_end will need to be modified. -
Very strange BI Publisher / OBIEE parameter query
Hello
I use BI Publisher to directly question on OBIEE server. I have a report that must accept two parameters: a string of text representing fiscal months and another text string representing the project. The problem I have is that one of the parameters is applied to the 'primary' query filter, while the other is used as a filter in a subquery. I don't seem to be able to get this to work (it's using OBIEE / BEEP 10.1.3.4.1)
The query that fails is:
SELECT contract. "' Contract number ', 'funding - ITD Metrics '. "' Total amount of funding - ITD.
'PROJECT - Performance '.
WHERE contracts. "" Contract number "(SELECT CONTRACT. "' Contract number ' OF 'Project - Performance' WHERE of the project. ("' Project ID" =: p_project_id)
"AND"Fiscal Calendar"". "" Fiscal month"=: p_fiscal_month
Here the really strange but - I can do this work if I use only 1 parameter, or if I use two parameters to the same 'level' - but as indicated above, with a parameter related to the main request and another for the subquery, it does not work.
It works:_ (replace param with hardcoded value fiscal month)
SELECT contract. "' Contract number ', 'funding - ITD Metrics '. "' Total amount of funding - ITD.
'PROJECT - Performance '.
WHERE contracts. "" Contract number "(SELECT CONTRACT. "' Contract number ' OF 'Project - Performance' WHERE of the project. ("' Project ID" =: p_project_id)
"AND"Fiscal Calendar"". "" Fiscal month"=" October 2011 "»
It works:_ (replace project ID param with hardcoded value)
SELECT contract. "' Contract number ', 'funding - ITD Metrics '. "' Total amount of funding - ITD.
'PROJECT - Performance '.
WHERE contracts. "" Contract number "(SELECT CONTRACT. "' Contract number ' OF 'Project - Performance' WHERE of the project. ("' The project ID ' = 'My project')
"AND"Fiscal Calendar"". "" Fiscal month"=: p_fiscal_month
_ Even that works (if I enter a number of contract in the project id parameter)(using the two params - but at the same "level" query)
SELECT contract. "' Contract number ', 'funding - ITD Metrics '. "' Total amount of funding - ITD.
'PROJECT - Performance '.
WHERE contracts. "" Contract number "=: p_project_id
"AND"Fiscal Calendar"". "" Fiscal month"=: p_fiscal_month
It's only when I try to put the two parameters in, and we're on the 'main' request and the other on the "subquery" I have problems.
Anyone seen this before? Y at - it something to get this working? Y at - it a bug?
p.s. the error messages given by BI Publisher are completely useless. In one case, the detailed error message is number 2. In either case, the error message is something about 25 data type...
Any help is GREATLY appreciated - it kills me.
THX,
ScottCan you check if this thread of the forum helps to pass parameters to the subquery
Suggestion is to use ' & ' in the inner query instead of ':' to bind variables.Can try you this?
-
error when trying to use ' {' in the query}
Hello
The below mentioned query gives error while trying to use ' {'}
Query:
Select s, table x (SEM_MATCH)
"{ ? s RDF: type < http://www.cs.com/sbip/dwh/mdm/data_modeling#Base_Term >.
? s? p? x}',
SEM_Models ('foundation'),
SEM_RuleBases ('OWLPRIME'),
SEM_ALIASES (SEM_ALIAS ('dm', 'http://www.cs.com/sbip/dwh/mdm/data_modeling#'),
((SEM_ALIAS ('Nice', 'http://www.w3.org/2002/07/owl#')), null, 'INVALID' value))
where regexp_like (x, 'Customers', 'i');
Error details:
ORA-29532: Java call terminated by eception Java exception: oracle.spatial.rdf.server.TokenMgrError: lexical error at line 1, column 1. Met: "{" (123), after:
ORA-06512: at the 'MDSYS. RDF_MATCH_IMPL_T', line 178
ORA-06512: at the 'MDSYS. RDF_MATCH_IMPL_T', line 67
ORA-06512: at line 4 level
I can't use the query filter Option.
Any solution?
Please let me know what I need to apply a patch?
Note: I use Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
Kind regards
Kouadio.Hello
For OPTIONAL in 11.1.0.7.0 support, you need the following patch
Patch 7600122: SYNTAX of BRACE, VIRTUAL MODELS, NETWORK INDEX AND HINTO SUPPORT FRAME
Support for filters SPARQL in SEM_MATCH is not available for 11.1.0.7.0. You need version 11.2.0.1.0 or later for the FILTER support. With 11.2.0.1.0, we recommend that you apply our latest game patches:
Patch 9819833: TECHNOLOGY SEMANTICS 11 G R2 FIX BUNDLE 2
All of the above fixes are available through My Oracle Support.
Thank you
Matt -
SQL Query - where where cause exists only once...?
I have a query/set result that I'm trying to / query filter.
What I need is, in two of the 5 columns in the result set, I need to return where registration exists only once. The other 3, they must meet certain criteria.
So, logically, it would be true for all: give me results where results in column 1, 2 there is only once AND Column3 is null and Column3 is null, and column 5 = Server
Not sure if that sense...? :/
one
Published by: Topher34 on March 11, 2010 16:18Try this way:
SQL> select id_user 2 from tbl1 3 group by id_user 4 having count(*)=1 and max(group_name) is null and max(nm_privilege) is null; ID_USER -------------------- AR55245 ASHARMA ADENYSENKO AREEFULLAH
Your qery becomes:
with tbl1 as ( select acct.id_user,sys.system_name,sys.fl_system_type,gu.group_name,obj.nm_privilege from acct left join gu on acct.id_user=gu.grantee and acct.system_id=gu.system_id left join sys on sys.system_id=acct.system_id left join obj on obj.grantee=acct.id_user and obj.system_id=acct.system_id ) select id_user from tbl1 group by id_user having count(*)=1 and max(group_name) is null and max(nm_privilege) is null
Max
http://oracleitalia.WordPress.com -
the filter value (with presentation variables) for applications using "SQL issued.
If I have a "emitted SQL":
SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3, saw_4 saw_4 (FROM)
SELECT saw_0 saw_0, saw_1 saw_1, SUM (saw_2) saw_2, SUM (saw_3) saw_3 SUM (saw_4) saw_4
Of
(
(
SELECT 'period '. "" YearMonth "saw_0,"Customer. " "" CustomerName "saw_1, COUNT ('dirty'. ("' SalesDate") saw_2, "Sales". "' No.OfConsumer ' saw_3, saw_4 0
CRM
WHERE ('period'. ("' YearMonth" > = 200904) AND ('period'. ("' YearMonth" < = 200910)
)
UNION ALL
(
SELECT 'period '. "" YearMonth "saw_0,"Customer. " "" CustomerName "saw_1, saw_2 0, saw_3 0, Count ("SuperSales". "Saw_4 SuperSalesDate") "
CRM
WHERE ('period'. ("' YearMonth" > = 200904) AND ('period'. ("' YearMonth" < = 200910)
)
) t1
Saw_0 GROUP, saw_1
ORDER BY saw_0, saw_1
) t2 ORDER BY saw_0
in fact, in this application, I would like to set up a filter to 'period '. "" YearMonth "using the variable of presentation.
is it possible to do?
Thank you!!Hi Forreging,
You can use variables of the presentation, but not if you directly set the SQL via the Advanced Options tab.
Instead, build up the first report like the first part of the statement of the UNION. Then use the "combined with a similar request" to build the logic for the second part of the query.
When approached in this way, you can set filters on each "subquery" via the criteria in other tab, OBIEE allows you to add an external to the level of the query filter when you go on the road to the SQL code in the Advanced tab.
Good luck and if you find this post useful, please give points!
Best regards
-Joe
-
Dynamic display of columns in the pivot query
I have a table called STUDENT_SCORE. I need to display the avarage score/month for 2 years and the monthly score until today "month.
Then assume that it is April 2009. The report will look like
Roll_id 2007avg 2008avg Jan09-Mar09 Feb 09
101 80.9 70.9 89.7 90.9 56.8
102 70.9 23.9 87.2 90.0 76.8
I tried a bit, but can't fix the monthly score display dynamically.
DDL/DML is as below
create the table STUDENT_SCORE
(number of roll_id,
date of mth_id,
The partition number);
insert into STUDENT_SCORE values
(101, to_date (January 1, 2006 ', ' dd/mm/yyyy'), 67.5);
insert into STUDENT_SCORE values
(101, to_date (February 1, 2006 ', ' dd/mm/yyyy'), 77.5);
insert into STUDENT_SCORE values
(101, to_date (March 1, 2006 ', ' dd/mm/yyyy'), 87.5).
insert into STUDENT_SCORE values
(101, to_date (April 1, 2006 ', ' dd/mm/yyyy'), 27.5);
insert into STUDENT_SCORE values
(101, to_date (May 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (June 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (July 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (August 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (September 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (October 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (November 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (December 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (January 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (February 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (March 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (April 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (May 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (June 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (July 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (August 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (September 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (October 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (November 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (December 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (1 January 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (February 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (March 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (April 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (May 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (June 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (July 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (August 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (September 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (October 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (November 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (December 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(101, to_date (January 1, 2009 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (January 1, 2006 ', ' dd/mm/yyyy'), 67.5);
insert into STUDENT_SCORE values
(102, to_date (February 1, 2006 ', ' dd/mm/yyyy'), 77.5);
insert into STUDENT_SCORE values
(102, to_date (March 1, 2006 ', ' dd/mm/yyyy'), 87.5).
insert into STUDENT_SCORE values
(102, to_date (April 1, 2006 ', ' dd/mm/yyyy'), 27.5);
insert into STUDENT_SCORE values
(102, to_date (May 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (June 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (July 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (August 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (September 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (October 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (November 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (December 1, 2006 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (January 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (February 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (March 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (April 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (May 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (June 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (July 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (August 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (September 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (October 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (November 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (December 1, 2007 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (1 January 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (February 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (March 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (April 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (May 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (June 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (July 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (August 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (September 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (October 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (November 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (December 1, 2008 ', ' dd/mm/yyyy'), 57.5);
insert into STUDENT_SCORE values
(102, to_date (January 1, 2009 ', ' dd/mm/yyyy'), 57.5);Hello
The script below produces what you want (as far as I can tell, without your desired results).
Student_score_smry subquery Gets the year and monthly averages of student_score.
It is completely static: it always produces 11 monthly columns (from January to November) and the names of columns hardcoded (m01 through m11).
For dynamic column names you need, I used SQL * COLUMN more orders.
To get the variable number of monthly columns you need, SELECT from the main query clause uses a script under (dynamic_month.sql) to only show the correct number (which can be 0).The student_score_wk_smry of subquery retrieves the weekly averages of the student_score_wk.
He, too, is completely static: it always produces 6 weekly columns with names hardcoded (w1 through w6).There are four preliminary motions, that write two scripts under:
Prelimiary C1, C2 and C3 queries write orders of COLUMN for annual, monthly and weekly columns in dynamic_columns.sql
Preliminary motion M written between 0 and 11 items in SELECT-clause in sub-script dynamic_month.sqlThe main script is:
SET FEEDBACK OFF SET LINESIZE 200 SET PAGESIZE 0 SET VERIFY OFF SPOOL dynamic_column.sql -- Preliminary query C1: Columns for last 2 years SELECT 'COLUMN y' || LEVEL || ' HEADING "' || TO_CHAR ( ADD_MONTHS ( &target_month , 12 * (-3 + LEVEL) ) , 'YYYY' ) || 'avg"' FROM dual CONNECT BY LEVEL <= 2 ; -- Preliminary query C2: 11 prior months in this year SELECT 'COLUMN m' || TO_CHAR (LEVEL, 'fm00') || ' HEADING "' || TO_CHAR ( ADD_MONTHS ( TRUNC (&target_month, 'YYYY') , LEVEL - 1 ) , 'MonYY' ) || '"' FROM dual CONNECT BY LEVEL <= 11 ; -- Preliminary query C3: 6 weeks before target_month WITH got_w_num AS ( SELECT SUBSTR (week_desc, 1, 6) AS mon_dd , ROW_NUMBER () OVER ( ORDER BY week_id DESC ) AS w_num FROM week WHERE TO_DATE (week_desc, 'Mon DD, YYYY') < &target_month ) SELECT 'COLUMN w' || TO_CHAR (7 - w_num) || ' HEADING "Week of ' || mon_dd || '"' FROM got_w_num WHERE w_num <= 6 ORDER BY w_num DESC ; SPOOL OFF -- Preliminary Query M: 0-11 months (in SELECT clause) SPOOL dynamic_month.sql SELECT ', m' || TO_CHAR (LEVEL, 'fm00') FROM dual WHERE MONTHS_BETWEEN (&target_month, TRUNC (&target_month, 'YYYY')) >= 1 CONNECT BY LEVEL <= MONTHS_BETWEEN (&target_month, TRUNC (&target_month, 'YYYY')) ; SPOOL OFF -- Restore SQL*Plus features suppressed earlier SET FEEDBACK ON SET LINESIZE 80 SET PAGESIZE 50 -- COLUMN Commands @dynamic_column.sql -- Main Query WITH student_score_smry AS ( SELECT roll_id , AVG (CASE WHEN TRUNC (mth_id, 'YYYY') = TRUNC (ADD_MONTHS (&target_month, -24), 'YYYY') THEN score END) AS y1 , AVG (CASE WHEN TRUNC (mth_id, 'YYYY') = TRUNC (ADD_MONTHS (&target_month, -12), 'YYYY') THEN score END) AS y2 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = TRUNC (&target_month, 'YYYY') THEN score END) AS m01 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 1) THEN score END) AS m02 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 2) THEN score END) AS m03 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 3) THEN score END) AS m04 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 4) THEN score END) AS m05 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 5) THEN score END) AS m06 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 6) THEN score END) AS m07 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 7) THEN score END) AS m08 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 8) THEN score END) AS m09 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 9) THEN score END) AS m10 , AVG (CASE WHEN TRUNC (mth_id, 'MM') = ADD_MONTHS (TRUNC (&target_month, 'YYYY'), 10) THEN score END) AS m11 FROM student_score GROUP BY roll_id ) , got_w_num AS ( SELECT week_id , ROW_NUMBER () OVER ( ORDER BY week_id DESC ) AS w_num FROM week WHERE TO_DATE (week_desc, 'Mon DD, YYYY') < &target_month ) , student_score_wk_smry AS ( SELECT roll_id , AVG (CASE WHEN W_NUM = 6 THEN score END) AS w1 , AVG (CASE WHEN W_NUM = 5 THEN score END) AS w2 , AVG (CASE WHEN W_NUM = 4 THEN score END) AS w3 , AVG (CASE WHEN W_NUM = 3 THEN score END) AS w4 , AVG (CASE WHEN W_NUM = 2 THEN score END) AS w5 , AVG (CASE WHEN W_NUM = 1 THEN score END) AS w6 FROM student_score_wk s JOIN got_w_num w ON s.wk_id = w.week_id WHERE w_num <= 6 GROUP BY roll_id ) SELECT NVL (ss.roll_id, ssw.roll_id) AS roll_id , y1, y2 @dynamic_month.sql , w1, w2, w3, w4, w5, w6 FROM student_score_smry ss FULL OUTER JOIN student_score_wk_smry ssw ON ss.roll_id = ssw.roll_id ORDER BY roll_id ;
Sub-script dynamic_column.sql might look like this:
COLUMN y1 HEADING "2007avg" COLUMN y2 HEADING "2008avg" COLUMN m01 HEADING "Jan09" COLUMN m02 HEADING "Feb09" COLUMN m03 HEADING "Mar09" COLUMN m04 HEADING "Apr09" COLUMN m05 HEADING "May09" COLUMN m06 HEADING "Jun09" COLUMN m07 HEADING "Jul09" COLUMN m08 HEADING "Aug09" COLUMN m09 HEADING "Sep09" COLUMN m10 HEADING "Oct09" COLUMN m11 HEADING "Nov09" COLUMN w1 HEADING "Week of Dec 21" COLUMN w2 HEADING "Week of Dec 28" COLUMN w3 HEADING "Week of Jan 04" COLUMN w4 HEADING "Week of Jan 11" COLUMN w5 HEADING "Week of Jan 18" COLUMN w6 HEADING "Week of Jan 25"
Other sub-script, dynamic_month.sql, might look like this:
, m01 , m02 , m03
Maybe you are looking for
-
Don't care about that for T440s
Please, could you give me an advice, where to find / buy for the new T440s and similar? I would use it for external battery or car charger and I can not find on the internet. Thank you!
-
Help! Also, I made a blunder to the top and erased a video on the computer after that I put on a DVD and wound up the burned DVD. I having trouble getting the video from the DVD and then turn the computer so I can work with it.
-
After use this printer (4635 HP officejet) successfully for several months now I get the message "the specified cartridges are not intended for this printer" even if they are the disp0layed of correct cartridges in the printer. I removed the cartridg
-
Files PES (embroidery)
I can't view my files PES (embroidery) from my computer... can someone help me?
-
I get CPD Watchdog Violation whenever I use word or excel
I get the CPD Watchdog Violation whenever I use word or excel. I uninstalled and reinstalled the program. Can someone help me solve this problem? Where can I find the dump file to send someone may view and solve problems? Thank you! Rachel