Intersect between two queries
Hi ,
I have a requirement which states me to count customers having two product A and B at the same time .
I can make a report with customer having product A and another report of customers having product B , but not able to find anyway to get count of customers having both A and B product at the same time .
I tried creating two reports and putting it as filter on the third report but it gives me error saying too many customers in the in clause.
Can anyone please help .
913302 wrote:
I have a requirement which states me to count customers having two product A and B at the same time .
I can make a report with customer having product A and another report of customers having product B , but not able to find anyway to get count of customers having both A and B product at the same time .
I tried creating two reports and putting it as filter on the third report but it gives me error saying too many customers in the in clause.
Can anyone please help .Hello,
Below is my analysis of your requirement: (Assuming only two distinct products)
PRODUCT CUSTOMER
A OHIO
B OHIO
A VIRGINIA
A NEBRASKA
B NEBRASKA
B MICHIGAN
From the above, your requirement is similar to get the counts of only the states that has both PRODUCT A and B.
select sum(count(distinct STATE)) STATE_count
from(
with t as
select 'A' as PRODUCT, 'OHIO' as STATE from dual
union all
select 'B' as PRODUCT, 'OHIO' as STATE from dual
union all
select 'A' as PRODUCT, 'VIRGINIA' as STATE from dual
union all
select 'A' as PRODUCT, 'NEBRASKA' as STATE from dual
union all
select 'B' as PRODUCT, 'NEBRASKA' as STATE from dual
union all
select 'B' as PRODUCT, 'MICHIGAN' as STATE from dual
select count(STATE ) STATE_count, product, STATE from t
where product in ('A','B')
group by product, STATE)
group by STATE
having count(1) > 1;
If you run the above SQL in Toad or any SQL Developer, you will get ONLY number of STATES which has both PRODUCTS A and B.
I hope you are clear now. Now try to implement the logic in Answers similar the below. I haven't tested this in Answers but should be something like below. If the below doesn't work, try to implement the logic from the SQL in Answers.
Now create a report in Answers with the following columns:
Columns:
1. STATE
2. PRODUCT
3. STATE (Name the column as STATE_COUNT)
Put this in the column formula: SUM(COUNT(DISTINCT STATE) BY STATE, PRODUCT)
Filters:
PRODUCT IN ('A','B')
STATE_COUNT > 1
Hope this helps.
Similar Messages
-
Outer join: difference between two queries
Below two queries that should give the same results in my opinion. I want all the records from u_protocol and only the value of pval.u_protocol_variable_value if present.
Why does the outer join in query2 doesn't work like in query1?
Query1:
select p.u_protocol_id, i.u_protocol_variable_value
from lims_sys.u_protocol p,
select pval.u_protocol_id, pval.u_protocol_variable_value
from lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval
where pvar.u_protocol_variable_id = pval.u_protocol_variable_id
and pvar.name = 'VALUE_Protocol_Group'
) i
where p.u_protocol_id = i.u_protocol_id (+)
Query2:
select prt.u_protocol_id, pval.u_protocol_variable_value
from lims_sys.u_protocol prt, lims_sys.u_protocol_variable pvar, lims_sys.u_protocol_value_user pval
where pvar.u_protocol_variable_id = pval.u_protocol_variable_id
and prt.u_protocol_id = pval.u_protocol_id (+)
and pvar.name = 'VALUE_Protocol_Group'In the first query restriction pvar.name = 'VALUE_Protocol_Group' is limited to your inline view. So when you do a outer join with the u_protocol table you will get the number of records which are there in the u_protocol table.
But when you gave the restriction pvar.name = 'VALUE_Protocol_Group' outside the inline view, the restriction was based on the resultset as a whole. So you will get only those records which have pvar.name = 'VALUE_Protocol_Group' condition satisfied.
Hope the following illustration helps:
SQL> CREATE TABLE TEST_TAB
2 AS
3 SELECT level col_1, chr(65+level-1) col_2 FROM Dual
4 CONNECT BY LEVEL <= 10
5 /
Table created.
SQL> SELECT * FROM TEST_TAB
2 /
COL_1 COL_
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
10 J
10 rows selected.
SQL> CREATE TABLE TEST_TAB_B
2 AS
3 SELECT level col_3, chr(65+level-1) col_4 FROM Dual
4 WHERE Level NOT IN (2,3,4)
5 CONNECT BY LEVEL <= 10
6 /
Table created.
SQL> SELECT * FROM TEST_TAB_B
2 /
COL_3 COL_
1 A
5 E
6 F
7 G
8 H
9 I
10 J
7 rows selected.
SQL> SELECT a1.col_1, a1.col_2, a2.col_3, a2.col_4 FROM TEST_TAB a1,
2 TEST_TAB_B a2
3 where a1.col_1 = a2.col_3(+)
4 order by a1.col_1
5 /
COL_1 COL_ COL_3 COL_
1 A 1 A
2 B
3 C
4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
10 J 10 J
10 rows selected.Notice the output without any extra conditions: You will get all the values from TEST_TAB and matching records from TEST_TAB_B. Non-matching records are outputed as NULL.
Following Query is resemblence to your first query
SQL> SELECT a1.col_1, a1.col_2, a2.col_3, a2.col_4 FROM TEST_TAB a1,
2 (SELECT * FROM TEST_TAB_B where col_4='A') a2
3 where a1.col_1 = a2.col_3(+)
4 order by a1.col_1
5 /
COL_1 COL_ COL_3 COL_
1 A 1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
10 J
10 rows selected.Here TEST_TAB_B Table is restricted with a condition which will restrict the inline view to have only one record. So when you outer join the inline view you will get output as shown above.
The following query resembles to your second query.
SQL> SELECT a1.col_1, a1.col_2, a2.col_3, a2.col_4 FROM TEST_TAB a1,
2 TEST_TAB_B a2
3 where a1.col_1 = a2.col_3(+)
4 and a2.col_4 = 'A'
5 order by a1.col_1
6 /
COL_1 COL_ COL_3 COL_
1 A 1 A
1 row selected.
SQL> DROP TABLE TEST_TAB_B
2 /
Table dropped.
SQL> DROP TABLE TEST_TAB
2 /
Table dropped.
SQL> To understand this lets break up the resultset.
Resultset brought by join condition would be something like :
COL_1 COL_ COL_3 COL_
1 A 1 A
2 B
3 C
4 D
5 E 5 E
6 F 6 F
7 G 7 G
8 H 8 H
9 I 9 I
10 J 10 JAgreed?
Now when you add the extra condition a2.col_4 = 'A' thecondition will act upon the above resultset there by restricting the records to:
COL_1 COL_ COL_3 COL_
1 A 1 AHope this helps.
Regards,
Jo -
Difference between two queries for no client installed
I have created a collection for all discovered computers with no client installed using the following query:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Client is null
If I go to Monitoring -> Client Status -> Client Activity and click on the link next to the pie chart for no clients installed I get a completely different result and they neither query contains the same computers as each other.
Anyone know what the exact query the link in the monitoring section is using and why the results between the two are completely different?
If would expect them to match up or at the very least that my first query should be the source of truth.If I use:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.Client is null OR SMS_R_System.Client = 0
and use the same limiting collection as the built in monitoring query "All Desktop and Server Clients" I actually get 0 results from the query. If I use "All Systems" as the limiting collection I still only get the same results
that I do with out also querying for "equals 0" as well.
I read one article that said that "equals 0" actually shows you the clients had the CCM client but it was uninstalled where "is Null" returns systems that never had the CCM client.
I don't know if this is accurate but it doesn't explain why a built in monitoring query would return inaccurate results. It only returns a fraction of the non-client systems that the above query returns and as mentioned, the systems returned in one
are not included in the other. -
Why left outer join is happening between two queries
Hi, I have 2 facts in my request. So 2 queries are getting generated D1 and D2. But OBIEE is doing a D1 left outer join on D2. I am not understanding from where this left outer join is coming. I want an inner join. Can anybody help.
thx,
paragHi Parag,
Can you please check it in your BMM layer column mapping and double click you join here you can find type option. Please change to type inner.
Go--> BMMLayer--> double click column Joins--> Type--> you can change what type you want.
Award Points it is useful.
Thanks,
Satya -
Data link problem between two queries in BIP data template
never mind. I solved.
Edited by: user5131789 on Mar 7, 2012 11:17 AMnever mind. I solved.
Edited by: user5131789 on Mar 7, 2012 11:17 AM -
How can we make an outer join (+) between 2 Queries
in the data model, i have 2 queries
i.e
Q_master and Q_detail
i want to make a data link between
these two queries and
also make an outer join between these
two queries(i.e. to display all the detail
records, whether they have details or not)
please reply is it possible ?
if yes then how?
plz write.
[email protected]
nullHello,
Left outer join behavior is what you get by default with a link between two queries in Reports.
If you want a full outer join behavior, you'll need to create a third query that selects the detail records that have no corresponding master, and also create an extra layout region to display them in as a default group left or group above won't pick up these extra records.
If you want right outer join behavior, you'll need to put in a summary in the master query that counts the rows in the detail, and then put in a format trigger in the master repeating frame that suppresses printing when there are no detail records. And you'll also need the third query and layout section as in the full outer join case.
Regards,
The Oracle Reports Team --skw -
Whats the difference between these two queries ? - for tuning purpose
Whats the difference between these two queries ?
I have huge amount of data for each table. its takeing such a long time (>5-6hrs).
here whice one is fast / do we have any other option there apart from listed here....
QUERY 1:
SELECT --<< USING INDEX >>
field1, field2, field3, sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end)
FROM
tab1 inner join tab2 on condition1 inner join tab3 on condition2 inner join tab4 on conditon3
WHERE
condition4..10 and
GROUP BY
field1, field2,field3
HAVING
sum( case when field4 in (1,2) then 1 when field4 in (3,4) then -1 else 0 end) <> 0;
QUERY 2:
SELECT --<< USING INDEX >>
field1, field2, field3, sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0))
FROM
tab1, tab2, tab3, tab4
WHERE
condition1 and
condition2 and
condition3 and
condition4..10
GROUP BY
field1, field2,field3
HAVING
sum( decode(field4, 1, 1, 2, 1, 3, -1, 4, -1 ,0)) <> 0;
[pre]My feeling here is that simply changing join syntax and case vs decode issues is not going to give any significant improvement in performance, and as Tubby points out, there is not a lot to go on. I think you are going to have to investigate things along the line of parallel query and index vs full table scans as well any number of performance tuning methods before you will see any significant gains. I would start with the Performance Manual as a start and then follow that up with the hard yards of query plans and stats.
Alternatively, you could just set the gofast parameter to TRUE and everything will be all right.
Andre -
Find intersection/union between two maps
Hello.
I'm trying to find out state changes between two maps.
I have two maps A and B, what I need to do is to find keys in A that doesn't exists in B and keys in B that doesn't exist in A.
If keys exists in both A and B I want to compare the values of those keys.
What would be the most effective way to implement this.
My first plan was to loop through the keys in A to find in B and loop through keys in B and find in A but I guess there is a more effective algorithm.
I'm also thinking about using java.util.Collections to find intersection/union between the keys in the maps but then I need to do a lookup in both
maps.
Any suggestions?
Regards
/FredrikFredrik wrote:
My scenario is this:
I'm writing a Swing app for administration of a clustered environment.
The keys in the map contains ip-address of cluster nodes, the value is a status/state for a node in the cluster.
I want to signal state change for the node in the GUI.
A state change happens if there is a new node in the cluster which means a new entry in the map since last checked or if a node
leaves the cluster a remove of entry in the map since last checked or if the status/state for the entry/ip has changed since last checked.
Regards
/FredrikBy your above senario, i don't think you have two objects of Map, there is only one object and you want to signal the change in GUI, whenever a object is added , removed or only value is changed (Key is same) to the Map.
Then i'll suggest below things:
1) to override hashcode and equal method. (Because whenever the put or putAll methods are called the hashcode and equal method checks in the bucket for equal and similar hashcode, and if its equal , then change the GUI for the existing Map).
2) As suggested earlier, override remove methods. (Whenever any object is removed, accordingly you can change the GUI).
3) As suggested earlier, override put and putAll method( whenever a new object is added, accordingly you can change the GUI).
And for this, i don't think you have iterate through the Map. -
Confused on syntax-combine two queries
I have two queries that I'm trying to combine, but can't figure out how to combine them ... successfully!?! The first query is pretty simple in that I'm looking at several fields from two different tables, no big deal.
The second query calculates the years, months, days between two dates that are used in the first query. I'm stumped on how to combine the queries so that they place nice with each other and return results.
Here's the first query ...
select
RTRIM(RTRIM(vpi.LastName) + ', ' + RTRIM(ISNULL(vpi.FirstName,''))) Employee,
convert(varchar,vpi.FromEffectiveDate,101) PositionStart,
convert(varchar,vpi.ToEffectiveDate,101) PositionChange,
convert(varchar,vpi.PositionStartDate,101) PositionStartDate,
vpi.PositionReason, vpi.PositionCode, vpc.PositionCodeDescription
from vhrl_positioninfo vpi
inner join position_codes vpc on vpi.PositionCode = vpc.PositionCode
Here's the second query ...
select
[Age] = convert(varchar, [Years]) + ' Years ' +
convert(varchar, [Months]) + ' Months ' +
convert(varchar, [Days]) + ' Days', *
from
select
[Years] = case when BirthDayThisYear <= Today
then datediff(year, BirthYearStart, CurrYearStart)
else datediff(year, BirthYearStart, CurrYearStart) - 1
end,
[Months]= case when BirthDayThisYear <= Today
then datediff(month, BirthDayThisYear, Today)
else datediff(month, BirthDayThisYear, Today) + 12
end,
[Days]= case when BirthDayThisMonth <= Today
then datediff(day, BirthDayThisMonth, Today)
else datediff(day, dateadd(month, -1, BirthDayThisMonth), Today)
end,
Birth = convert(varchar(10) ,Birth, 121),
Today = convert(varchar(10), Today, 121)
from
select BirthDayThisYear =
case when day(dateadd(year, datediff(year, BirthYearStart, CurrYearStart), Birth)) <> day(Birth)
then dateadd(day, 1, dateadd(year, datediff(year, BirthYearStart, CurrYearStart), Birth))
else dateadd(year, datediff(year, BirthYearStart, CurrYearStart), Birth)
end,
BirthDayThisMonth =
case when day(dateadd(month, datediff(month, BirthMonthStart, CurrMonthStart), Birth)) <> day(Birth)
then dateadd(day, 1, dateadd(month, datediff(month, BirthMonthStart, CurrMonthStart), Birth))
else dateadd(month, datediff(month, BirthMonthStart, CurrMonthStart), Birth)
end,
from
select BirthYearStart = dateadd(year, datediff(year, 0, Birth), 0),
CurrYearStart = dateadd(year, datediff(year, 0, Today), 0),
BirthMonthStart = dateadd(month, datediff(month, 0, Birth), 0),
CurrMonthStart = dateadd(month, datediff(month, 0, Today), 0),
from
select birth = convert(datetime, fromeffectivedate) ,
Today = case when convert(datetime, toeffectivedate) = '3000-01-01'
THEN convert(datetime, convert(int,getdate()))
else vpi.toeffectivedate
end
from vHRL_PositionInfo vpi inner join position_codes vpc
on vpi.PositionCode = vpc.PositionCode
) aaaa
) aaa
) aa
)a
Here's the sample data ...
vpi table ...
LastName FirstName FromEffectDate ToEffectDate PosStartDate PosReason PosCode
Doe John 2001-10-15 3000-01-01 10-15-2001 Transfer OperPack
Smith Tom 1994-11-28 2001-10-14 1994-11-28 New Hire OperDC
vpc table ...
PosCode PosDescription
OperPack Pack Line Operator
OperDC Descaler Operator
This is what the results should look like ...
John, Doe 2001-10-15 3000-01-01 10-15-2001 Transfer OperPack Pack Line Operator 6 Years 11 Months 16 Days
John, Doe 1994-11-28 2001-10-14 1994-11-28 New Hire OperDC Descaler Operator 6 Years 6 Months 19 Days
I know the date calculation piece adds 5 additional fields to the end, but they are not needed for the final report. Any help would be greatly appreciated! Thank you! JenaYour query suggests you're not using Oracle. Please post in your relevant database forum.
-
Use of "findByMultipleParameters" for "OR " between two Query Filters
Hi,
I am also working in CE7.1 .I have a query regarding the use of "findByMultipleParameters" .
That is how to use "OR " between two Query Filter condition,because if we add multiple queries into Query Filter List it will by default taking "AND " .
For an example, I have to pull data from a table/BO with a condition col A = 10 OR ( col B > 100 AND col c = "XYZ") .
My code snippet looks like given below.......
List queryFilters = new ArrayList();
QueryFilter queryFilterOne = QueryFilterFactory.createFilter("ROLLUMBER",Condition.EQ, rollNumber);
QueryFilter queryFilterTwo = QueryFilterFactory.createFilter("NAME",Condition.EQ, "123");
queryFilters.add(queryFilterOne);
queryFilters.add(queryFilterTwo);
List students = studentServiceLocal.findByMultipleParameters(queryFilters, false, "xyz");
I have tried all these and found all of them deprecated,Please suggest something appropriate.Your quick response will help a lot.
//queryFilterOne.setAction(QueryFilter.OPERATION_OR);
//QueryFilterFactory.createBoolOperator(queryFilterOne.OPERATION_OR);
//queryFilters.add(QueryFilter.OR);
//queryFilters.add(queryFilterOne.setOperation(QueryFilter.OPERATION_OR));
My another Query is what is the role of implCheck(Boolean),findByName(String) in "findByMultipleParameters()" ?
Thanking you for your help in advance.
Regards,
Sonali
Edited by: Sonali Das on Sep 14, 2010 2:32 PMHi Praveen/Harris,
As Mr Bhanu said , we can get the result by using formula variable defined on attribute with replacement path as processing type.
There is document in https://websmp101.sap-ag.de/bi
in infoindex->How to Calculate with attributes
To findout the difference between formula variable and current date, define one more formula variable with processing as custoemr exit.And fill this variable with sy-datum or something else.
with rgds,
Anil Kumar Sharma .P -
Difference in the display/rendering between two 7.4 portal systems
Hi everyone,
At this moment we are faced with a difference in the display/rendering between two 7.4 portal systems (see red area’s in screenshots). Both systems are green field installations.
At our LAB system with EP-BASIS 1000.7.40.7.0.20140421205300 and EP-RUNTIME 1000.7.40.7.0.20140414131600 the portal is rendered as follows:
Our development system DEV is based on EP-BASIS 1000.7.40.8.7.20141217073700 and EP-RUNTIME 1000.7.40.8.13.20150106224500. The portal is displayed as follows:
Both portal systems use the standard SAP Gold Reflection theme.
The expectation was that the DEV portal would have the same view as the LAB portal. Unfortunately, it appears that the DEV portal falls back to the older standard SAP Tradeshow theme when displaying (for example) the Portal Content Studio or the UWL. Different stylesheets (CSS) are loaded. There is no unified rendering and in our opinion this is not correct.
SCN provides much information about the various rendering problems that exists in the use of Internet Explorer in combination with the SAP Portal. However, it is unclear to us where to start with the analysis of this problem.
Answers / suggestions to the following questions will be highly appreciated:
Is it correct that the portal by default should make use of UR when the SAP Gold Reflection theme is used?
Is the difference of rendering caused by the difference in the versions of the EP BASIS / EP RUNTIME? (DEV portal has higher SP/patch level than LAB);
How to investigate this issue further and finally solve it?
Thanks in advance!
Kind regards, AllanHi Allan
I hope you are well and many thanks for using the SAP Discussion Forums .
Ok firstly in relation to this particular query, you can find additional information in the following documentation SAP Note:1852400 - UI theme designer (main note) .
Regarding the GOLD Reflection theme from a general perspective this is supported only alongside the UFP framework.
SAP Gold Reflection supports only Unified Rendering Lightspeed
In relation to your two other queries. Could you kindly clarify which particular version of IE you are presently running and also if compability mode is presently enabled/disabled?
Reference Documentation Look & Feel, Framework Pages and Portal Navigation
http://scn.sap.com/docs/DOC-23058
Kindly update me as per your findings.
Kind Regards
Troy Cronin - Enterprise Portal Support Engineer
Follow - Troy Cronin -
Can we use ALE to send purchase requisition between two systems?
Dear Gurus,
Can we use ALE to send Purchase Requisition between two R/3 systems?
Source system is A. Target system is B. Target system B is the customer of A.
When A wants Material, it will check the availability.
If available, it will create Reservation.
If not available, it will create PR and send it to Target system B. Since B is a customer of A, B will, in turn, create PO and send it to its Vendors.
We plan to use ALE/IDoc. I tried to find out the message type for PR. But it's not available.
Can anyone suggest me how to do that?
Thanks & Regards,
Neeraj K.Hello,
The technical answer is yes. You could use the message PREQCR / PREQCR01 or PREQCR02 for your requirement of transferring Purchase Request via ALE. Since I am not a process expert, it would not be possible for me to comment on your process needs.
Please let me know if you have further technical queries.
Hope this helps,
Best Regards, Murugesh AS -
Dist between two lat/long's in USA
Hello,
Can anyone please give me the function(Oracle or some other function) to find the distance between two points(Both of them are in lat/longs). Both the points are within the boundary of US.
Thanks,Hi,
In Oracle 8.1.6, we have Beta support
for Coordinate Systems. There is
Beta users guide available under PRODUCTS/SPATIAL.
With this functionality, you can calculate
the distance between two points
very accuratly.
Here is an example. I will go into details
below. Hope this helps. Thanks.
Dan
======
SAMPLE SQL: (sorry about the formatting)
select
mdsys.sdo_geom.sdo_length (
mdsys.sdo_cs.transform (
mdsys.sdo_geometry (2002, 8307, null,
mdsys.sdo_elem_info_array (1,2,1),
mdsys.sdo_ordinate_array (
-73.983014309,
40.749544981,
a.geometry.sdo_point.x,
a.geometry.sdo_point.y)),
MDSYS.SDO_DIM_ARRAY(
MDSYS.SDO_DIM_ELEMENT(
'X', -180, 180, .00000005),
MDSYS.SDO_DIM_ELEMENT(
'Y', -90, 90, .00000005)),
41004),
.00000005) * 6.213712e-04 DISTANCE_IN_MILES
from test_abi a
where
mdsys.sdo_nn (
a.geometry,
mdsys.sdo_geometry (
1, 8307,
mdsys.sdo_point_type (-73.983014309,
40.749544981,
null),
null, null),
'SDO_NUM_RES = 1') = 'TRUE';
DESCRIPTION:
============
1) The above query is returning the
nearest point to
(-73.983014309, 40.749544981)
and also returning the distance in miles.
TEST_ABI.geometry is stored in
longitude/latitude with 8307
as the SRID.
Note, if you set the SRID in the
SDO_GEOMETRY object, you must also
set the SRID in USER_SDO_GEOM_METADATA.
To find out more info on SRID 8307,
you can execute the following:
select wktext
from mdsys.cs_srs
where srid = 8307;
SDO_NN is the operator used to find
the nearest neighbor.
For nearest neighbor queries, you
may want to try using RTREE indexes,
also Beta in 8.1.6.
To create an RTREE index, omit
SDO_LEVEL and SDO_NUMTILES from
the create index statement of your
spatial index.
We plan to fully profile RTREE indexes
in 8.1.7 and recommend them when
appropriate. Nearest neighbor is an
excellent candidate for an RTREE index.
2) In the SELECT clause, we are calling
two functions:
SDO_LENGTH
SDO_CS.TRANSFORM
The first argument passed into SDO_LENGTH
is the return value from
CS_TRANSFORM (which will be a
projected SDO_GEOMETRY object).
The second argument to SDO_LENGTH
is an SDO_TOLERANCE.
3) The first argument to CS_TRANSFORM
is an SDO_GEOMETRY constructor for a
line string, where the first point of
the linestring is
(-73.983014309, 40.749544981),
and the second point is the nearest
neighbor resulting from SDO_NN.
This goal here is to project the
linestring so we can get an accurate
result from SDO_LENGTH.
The second argument to CS_TRANSFORM
a dim_array.
The third argument to CS_TRANSFORM
is the target SRID. In this example,
SRID 41004 is used. This will be
fairly accurate for the continental US.
The geometry constructor for the
linestring will be projected to
SRID 41004.
If more accurate results are desired,
you should use an SRID that corresponds
to a specific state plane projection.
Query the WKTEXT column in MDSYS.CS_SRS
to pick appropriate SRID's for projection.
i.e. If I knew my nearest neighbor result
is going to be in Georgia, I might
use SRID 1001 instead of 41004.
4) In the result of the select list, I am
multiplying by 6.213712e-04,
the conversion factor from meters to
miles.
Hope this helps. Thanks.
Dan -
Drawing an arrow between two rectangle shapes
i am trying to draw an arrow between two rectangle shapes. the arrow will start from the center of one rectangle and end with the arrow tip at the edge of the other rectangle. i actually draw the arrow first, and draw the rectangles last so the effect of where the arrow starts will seem to come from the edge and not the center.
i have code using some trigonmetry that works for squares, but as soon as the shape becomes a rectangle (i.e. width and height are not the same), the drawing breaks.
can i detect where a line intersects with a shape through clipping and use that point location to draw my arrow head? if so, how?Here's one way to do this using the rule of similar triangles.
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class Pointers extends JPanel {
Rectangle r1 = new Rectangle(40,60,100,150);
Rectangle r2 = new Rectangle(200,250,175,100);
int barb = 20;
double phi = Math.toRadians(20);
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(Color.blue);
g2.draw(r1);
g2.draw(r2);
g2.setPaint(Color.red);
g2.draw(getPath());
private GeneralPath getPath() {
double x1 = r1.getCenterX();
double y1 = r1.getCenterY();
double x2 = r2.getCenterX();
double y2 = r2.getCenterY();
double theta = Math.atan2(y2 - y1, x2 - x1);
Point2D.Double p1 = getPoint(theta, r1);
Point2D.Double p2 = getPoint(theta+Math.PI, r2);
GeneralPath path = new GeneralPath(new Line2D.Float(p1, p2));
// Add an arrow head at p2.
double x = p2.x + barb*Math.cos(theta+Math.PI-phi);
double y = p2.y + barb*Math.sin(theta+Math.PI-phi);
path.moveTo((float)x, (float)y);
path.lineTo((float)p2.x, (float)p2.y);
x = p2.x + barb*Math.cos(theta+Math.PI+phi);
y = p2.y + barb*Math.sin(theta+Math.PI+phi);
path.lineTo((float)x, (float)y);
return path;
private Point2D.Double getPoint(double theta, Rectangle r) {
double cx = r.getCenterX();
double cy = r.getCenterY();
double w = r.width/2;
double h = r.height/2;
double d = Point2D.distance(cx, cy, cx+w, cy+h);
double x = cx + d*Math.cos(theta);
double y = cy + d*Math.sin(theta);
Point2D.Double p = new Point2D.Double();
int outcode = r.outcode(x, y);
switch(outcode) {
case Rectangle.OUT_TOP:
p.x = cx - h*((x-cx)/(y-cy));
p.y = cy - h;
break;
case Rectangle.OUT_LEFT:
p.x = cx - w;
p.y = cy - w*((y-cy)/(x-cx));
break;
case Rectangle.OUT_BOTTOM:
p.x = cx + h*((x-cx)/(y-cy));
p.y = cy + h;
break;
case Rectangle.OUT_RIGHT:
p.x = cx + w;
p.y = cy + w*((y-cy)/(x-cx));
break;
default:
System.out.println("Non-cardinal outcode: " + outcode);
return p;
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new Pointers());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
} -
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
_1st query_
select
(CASE WHEN SUBSTR(R1.RA_NO,1,3)= 'NRA' THEN 'Damansara Uptown One Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'ORA' THEN 'Damansara Uptown Two Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'VRA' THEN 'Damansara Uptown Realty Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'URA' THEN 'Uptown Elite Sdn. Bhd.'
when SUBSTR(R1.RA_NO,1,3)= 'WRZ' THEN 'U5 Management Corporation Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,2)= 'FR' THEN 'See Hoy Chan Facilities Management Sdn.Bhd.' END) Landlord
,TO_CHAR(C1.COLL_DTE,'RRRRMM') MONTH1
,SUM(C2.TRN_AMT) UPTO_31
, SUM(CASE WHEN to_char(C1.COLL_dte) BETWEEN to_date(:P_FROM_DATE,'dd.mm.yyyy') AND '16-'||to_date(:P_TO_DATE,'dd.mm.yyyy') THEN C2.TRN_AMT END) UPTO_15
from ra1 R1, COLLECT1 C1 , COLLECT2 C2
where
(to_char(C1.COLL_dte) between to_date(:P_FROM_DATE,'dd.mm.yyyy') AND to_date(:P_TO_DATE,'dd.mm.yyyy'))
and (SUBSTR(R1.RA_NO,1,2)= 'FR' or SUBSTR(R1.RA_NO,1,3) in ('NRA' ,'ORA','VRA','URA','WRZ'))
AND R1.RA_NO = C2.INV_NO
AND C2.COLL_NO = C1.COLL_NO
GROUP BY
(CASE WHEN SUBSTR(R1.RA_NO,1,3)= 'NRA' THEN 'Damansara Uptown One Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'ORA' THEN 'Damansara Uptown Two Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'VRA' THEN 'Damansara Uptown Realty Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,3)= 'URA' THEN 'Uptown Elite Sdn. Bhd.'
when SUBSTR(R1.RA_NO,1,3)= 'WRZ' THEN 'U5 Management Corporation Sdn. Bhd.'
WHEN SUBSTR(R1.RA_NO,1,2)= 'FR' THEN 'See Hoy Chan Facilities Management Sdn.Bhd.' END)
,TO_CHAR(C1.COLL_DTE,'RRRRMM')
_2query_
select sum(decode(substr(ra_no,1,7),'NRA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) NRA
,sum(decode(substr(ra_no,1,7),'VRA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) VRA
,sum(decode(substr(ra_no,1,7),'ORA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) ORA
,sum(decode(substr(ra_no,1,7),'FR'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) FR
,sum(decode(substr(ra_no,1,7),'WRZ'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) WRZ
,sum(decode(substr(ra_no,1,7),'URA'
||to_char(to_date(:P_FROM_DATE,'dd.mm.yyyy'),'yymm'),tot_amt,0)) URA
from RA1
above are the two queries i need to join these two queries by naming the second query column name as total .1st query output is ----------
LOCATION MONTH1 UPTO_31 UPTO_15
U5 Management Corporation Sdn. Bhd. 201001 15250 8900
Uptown Elite Sdn. Bhd. 201001 3000 1500
See Hoy Chan Facilities Management Sdn.Bhd. 201001 917115.45 584876.5
Damansara Uptown Two Sdn. Bhd. 201001 757277.45 495362.95
Damansara Uptown One Sdn. Bhd. 201001 881558.65 404872.45
Damansara Uptown Realty Sdn. Bhd. 201001 321675.8 150508.6
2nd query output is -------
NRA ORA VRA URA WRZ FR
2323.31 95945 34367.8 34267 4343 343
Now what i need is
LOCATION MONTH1 UPTO_31 UPTO_15 TOTAL
U5 Management Corporation Sdn. Bhd. 201001 15250 8900 2323.31
Uptown Elite Sdn. Bhd. 201001 3000 1500 95945
See Hoy Chan Facilities Management Sdn.Bhd. 201001 917115.45 584876.5 34367.8
Damansara Uptown Two Sdn. Bhd. 201001 757277.45 495362.95 34267
Damansara Uptown One Sdn. Bhd. 201001 881558.65 404872.45 4343
Damansara Uptown Realty Sdn. Bhd. 201001 321675.8 150508.6 343above is the clear picture what i need , i don't know how to do it please help me
Edited by: user9093689 on Feb 21, 2010 8:06 PM
Maybe you are looking for
-
What do I lose by removing "Quicktime Plugin.plugin"?
After upgrading to Leopard (Erase and install, then migrate data from a backup off an external HD), all the flash videos and ads had the Quicktime icon with a question mark on it. After searching through Apple discussions and google, I found a site t
-
Hi everybody, I'm trying to get a list of running processes, and for each process I need its Process ID, Process Name, and the command line that run this process. I found a way to get everything but the command-line, by JNI wrappers (below are links
-
Connect of 2 SAP BW systems to one SAP Enterprise Portal
Hi! I have 2 SAP BW systems that should be integrated into SAP Enterprise Portal. I currently have already one SAP system entry "SAP_BW" within SAP EP. Questions Is it possible to define second entry for second SAP BW system in order to use 2 SAP BW
-
Openoffice quickstart for command line available
hi i put the ooqstart package up to staging (since staging is not reachable build it yourself it's a very small app) now it is possible to use the openoffice quickstart with every wm/de you want all you have to to is to put a bash script in the autos
-
Does Keynote '09 have Style Sheets for quickly formatting text?