How do I join together these two queries?
Hi I have these queries:
select br_no, br_managersname from BRANCH order by br_managersname;
select sum(rent_endkms-rent_startkms) as "TOTAL KMS TRAVELLED" from RENTAL group by BR_NO having SUM(rent_endkms-rent_startkms) = (select MAX(sum(rent_endkms-rent_startkms)) from RENTAL group by BR_NO);
They each output their own tables, but I wanna join them together so they output as one table. Unfortunately, I really suck at joining tables. Can anyone help?
Hmm... Not enought information again... Any way, let me consider br_no as the key between the two query. In that case i came up with this.
with query1
as
select br_no, br_managersname
from BRANCH order by br_managersname
query2
as
select br_no, sum(rent_endkms-rent_startkms) as total_kms_travelled
from RENTAL
group by BR_NO
having SUM(rent_endkms-rent_startkms) = (select MAX(sum(rent_endkms-rent_startkms))
from RENTAL
group by BR_NO)
select q1.bar_no, q1.br_managersname, q2.total_kms_travelled
from query1 q1
join query2 q2
on q1.br_no = q2.br_no
Similar Messages
-
Hi experts,
I need to join two queries but not sure how:
select id from test_table1;
select *
from table(f_function(null
,null
,1 -- the id
,sysdate);One query has IDs needed to run the second query. Is there a way to join those two?
The result should be all columns from test_table1 + all columns from f_function.
Best regards,
Igor
Edited by: Igor S. on Mar 8, 2013 5:18 AMHi,
Igor S. wrote:
select *
from test_table1,
table(
f_function(
null,
null,
id,
sysdate
select *
from test_table1,
table(
f_function(
null,
null,
id,
sysdate
) xyz
where test_table1.id = xyz.id
/So these two queries are the same?Try it and see.
You'll find that the 2nd one produces an error. But if you change it to
select *
from test_table1,
table(
f_function(
null,
null,
id,
sysdate
) -- No alias here
) xyz -- Alias here, instead
where test_table1.id = xyz.id
/Then, assuming f_function produces a column called id, it will work.
Whether it produces the same results or not depends on what the function returns, and whether either id is NULL.
If the id column that the function returns is the same as the id value that you pass to it, and is never NULL, then the 2 queries will produce the same results.
Either way, each row of test_table1 will be joined to each row that the function produces with the argument(s) from that row. The column names produced by the function and the values in those columns are determined by the function; they do not need to have anything in common with any table. In practice, a function like f_function will usually not return an column that is always identical to any of its inputs, since that value is already available from the input. -
Joining these these two queries (one regular and one grouped)
Hello
I have these two queries I would like to join, however the later is a grouped query how can I join it with the first query?
Has to be joined on EventId. The second query is a total table scan.
SELECT AH.EventID,
AH.TechnicalAddress, AH.AlarmAlias, AH.AlarmPath as [OrgAlarmPath], AH.AlarmCounter as AlarmCount, AH.EventDateTime as EventTime,
AH.[Priority], AH.AlarmMessage, AH.EventText, AH.CallListName, AH.AlarmReadDate as EndTime,
AH.alh_EventEndedUserRemark as [EndRemark] --, SUM(seconds) here, and AlarmSessions here
FROM AlarmHistory AH
WHERE (AH.HeartbeatAlarm = 0 OR AH.HeartbeatAlarm IS NULL) AND
((AH.CallListID IS NOT NULL) OR (AH.alh_IsForStatistics = 1)) AND
(NOT (AH.alh_t_EventSubCode is NULL or AH.AlarmReadByUserID is NULL))
ORDER BY AH.EventID DESC
SELECT ia.eventID, SUM(DATEDIFF(SECOND,ia.eventTime,r.eventTime)) AS seconds, COUNT(*) as AlarmSessions
FROM alarmHistoryLog ia
INNER JOIN alarmHistoryLog r
ON ia.EventId = r.EventId
AND r.EventTypeId = 2
AND r.EventSeq = (SELECT MIN(eventSeq) FROM alarmHistoryLog WHERE eventSeq > ia.EventSeq AND EventTypeId = 2)
WHERE ia.EventTypeId = 0
group by ia.EventId
order by EventId desc
HenryTry the below:
;with ctefirst as
SELECT AH.EventID,
AH.TechnicalAddress, AH.AlarmAlias, AH.AlarmPath as [OrgAlarmPath], AH.AlarmCounter as AlarmCount, AH.EventDateTime as EventTime,
AH.[Priority], AH.AlarmMessage, AH.EventText, AH.CallListName, AH.AlarmReadDate as EndTime,
AH.alh_EventEndedUserRemark as [EndRemark] --, SUM(seconds) here, and AlarmSessions here
FROM AlarmHistory AH
WHERE (AH.HeartbeatAlarm = 0 OR AH.HeartbeatAlarm IS NULL) AND
((AH.CallListID IS NOT NULL) OR (AH.alh_IsForStatistics = 1)) AND
(NOT (AH.alh_t_EventSubCode is NULL or AH.AlarmReadByUserID is NULL))
), ctesecond as
SELECT ia.eventID, SUM(DATEDIFF(SECOND,ia.eventTime,r.eventTime)) AS seconds, COUNT(*) as AlarmSessions
FROM alarmHistoryLog ia
INNER JOIN alarmHistoryLog r
ON ia.EventId = r.EventId
AND r.EventTypeId = 2
AND r.EventSeq = (SELECT MIN(eventSeq)
FROM alarmHistoryLog WHERE eventSeq > ia.EventSeq AND EventTypeId = 2)
WHERE ia.EventTypeId = 0
group by ia.EventId
Select A.*,B.seconds,B.AlarmSessions From ctefirst A
Inner join ctesecond B On A.EventId = B.EventID
Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
[Blog] -
How do you join together two iCloud accounts?
How do you join together two iCloud accounts of mine?
You would need to export the data from one account, using the respective apps, sign out of it, sign into the other, and import the data.
Alternately, you can setup the other account as a secondary icloud account in sys prefs >> internet accounts. A secondary account is limited compared to the main one, though.
Actual merging the Apple ID/icloud accounts, as stated, is not possible. -
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 -
QUESTION: In Elements 12, how do I join together separate slideshows into a single integrated alideshow?
I hate to say this, but there is no way to put 1280X720 footage on a 1920X1080 sequence and upscale it to match the frame size without losing some quality. Basically, you are asking Premiere Pro to provide new pixels that were not in the original video. That is seldom a really good idea. You might want to try investing in program designed to upscale video. I have never used this, but there is a free trial, so give it a shot: http://www.infognition.com/VideoEnhancer/
Of course, it all depends on the content. Try it with Premiere Pro. Only you can judge. However, you might need to consider putting all of your 1920X1080 on a 1280X720 sequence instead, and just produce your video at that size.
Or, once again, this depends on the content, put some sort of frame around the smaller footage, either a blurred out version of the upscaled footage - lots of TV stations do this with 4:3 footage on a HD program, or purposefully make it even a little smaller, or crop it, and use parts of the same video in Picture-In-Picture. You have seen this before. A person talking on the phone in a larger frame to the left, and on the right a closeup of the mouth, or maybe a clip of the person they are talking to. Or use some B-Roll in the PiP.
Get imaginative, because you already know that you messed up, so perhaps make it look like you did it on purpose. -
Query problem, two working queries how to left join together?
Hello,
I have a two queries that I have been trying to put together for a couple days. I'm frazzled. Hopefully you can help.
The first query returns all rows from the database. The second query returns only one row (because the way it is currentlly set up in the Where clause). So I know that will have to change. For each row returned in Query1, I need the two fields from Query2 included
(so the link would be through client.Id (which is an indexed field) or client.Accountnumber?
This query, returns all records in the database:
Select client.Id, client.accountnumber, client.Namelast,
dmlocation.city ||', '||dmlocation.state as CityState,
client.salesTerritory_client ||'-'|| dmuser.namefirst_user ||' '|| dmuser.namelast_user as Territory,
MaxDates.LastRun, client.creditrisk, client.customercategory
from client
Left join fctclientcoverage on fctclientcoverage.client_id = client.id
Left join dmlocation on fctclientcoverage.location_id = dmlocation.id
Left join dmuser on dmuser.id = client.id
Left join (Select to_char(Max(dmdate.calendardate),'MM/DD/YY') as LastRun, Client.Id
from dmdate, client, fctadorder
where dmdate.id = fctadorder.lastinsert_date_id and client.id = fctadorder.primaryorderer_client_id
group by client.id) MaxDates ON client.id = MaxDates.Id
where(fctclientcoverage.Ccoverrecordstopdate Is Null)
Order by client.namelast;
Query 2, only returns 1 row, so for each row returned above, the two fields selected in this query should accompany each row. But how to link these two selects using the client.accountnumber (or perhaps by dmcliet.id)?
Select booked.CurRev, booked.LastRev from (
Select (sum(Case When dmDate.CalendarDate >= '29-DEC-2008' and dmDate.CalendarDate < '
Then fctinsertchargedetail.Amount_insertDetail Else 0 End)) As CurRev,
(sum(Case When dmDate.CalendarDate >= '29-DEC-2007' and dmDate.CalendarDate < '
Then fctinsertchargedetail.Amount_insertDetail Else 0 End)) As LastRev
from fctAdorder
Inner Join client On fctAdorder.primaryorderer_client_id = client.id
Inner Join fctinsertion On fctAdorder.id=fctinsertion.fctAdorder_id
Inner Join fctinsertchargesummary On fctinsertion.id=fctinsertchargesummary.insertion_id
Inner Join dmDate On fctinsertion.insert_date_id=dmDate.id
Inner Join fctinsertchargedetail On fctinsertchargesummary.id=fctinsertchargedetail.insertchargesummary_id
WHERE client.accountnumber = '12345678' and
dmDate.CalendarDate >= '29-DEC-2007' And dmDate.CalendarDate < ') booked;
Thanks for your time.Yes, You are correct!
I just recently got the query working with the aid of another forum.
The sad part is, all though the first query took 11 seconds to return 180,000 rows (thats good); The second query took 4 minutes to calculate and return all it's rows (that's bad). Together the query ran for over 4 minutes. Way too slow.
Being brand new to oracle I have to try and figure away to cut this time down. Perhaps I'm not considering something?
I orginally brought into my .net app the results from the first query and then in the rowdatabound event I queried each row to get the information needed from the second query. That was way too slow also. It was recommended to try and return all needed data at once.
I've been given a task to emulate a current application, (which I do not have access to it's code), that brings back all of this same information that I am using. It only takes them maybe 15 seconds to run, to bring back all. Of course they were experienced oracle sql developers.
So I guess my next step is to try and improve that second query. Thanks for replying to this Frank. I'll be back. Are you or is anyone good at knowing how to optimzie queries? I'm reading a book now trying out suggestions. Nothing is working yet.
thanks -
I have two queries. The First one is long but very simple. All it has is long list of columns.
First one:
SELECT CL.CLIENT_ID, CA.CASE_ID, to_char(SYSDATE,'RRMMDD'),
CL.MASTER_CLIENT_ID,
CL.NAME1,
nvl(CL.NAME2,' '),
nvl(CL.ADDRESS1,' '),
nvl(CL.ADDRESS2,' '),
CL.POCO_POSTAL_CODE, nvl(CL.CITY,' '),
nvl(CL.AUTO_SURV_CODE,0),
CA.Col_Collector_Id
FROM CLIENT CL, CASES CA
WHERE CA.CL_CLIENT_ID = CL.CLIENT_ID AND
CA.CASE_ID = :current_case_id
Second one:
SQL SELECT nvl(REF_NO,' '), nvl(to_char(DATE_OF_JUDGEMENT,'rrmmdd'),' ')
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8) AND
CA_CASE_ID = :current_case_id AND
PETITION_DATE = (SELECT max(PETITION_DATE)
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8)
AND CA_CASE_ID = :current_case_id
AND ROWNUM < 2 );
The :current_case_id is passed as a parameter. The table in the second query i.e. CASE_INSTANCES is related to the first query with the CA_CASE_ID. Not all records fetched by the first query have a record in the second query. So you might have to use a LEFT JOIN or something. trying to join these two has worn me out. Please help me out someone.Hi,
Simplified Solution:
SELECT * FROM (
SELECT CL.CLIENT_ID, CA.CASE_ID, TO_CHAR(SYSDATE,'RRMMDD'),
CL.MASTER_CLIENT_ID,
CL.NAME1,
NVL(CL.NAME2,' '),
NVL(CL.ADDRESS1,' '),
NVL(CL.ADDRESS2,' '),
CL.POCO_POSTAL_CODE, NVL(CL.CITY,' '),
NVL(CL.AUTO_SURV_CODE,0),
CA.Col_Collector_Id
FROM CLIENT CL, CASES CA
WHERE CA.CL_CLIENT_ID = CL.CLIENT_ID ) a,
(SELECT NVL(REF_NO,' '), NVL(TO_CHAR(DATE_OF_JUDGEMENT,'rrmmdd'),' '),CA_CASE_ID
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8) AND
CA_CASE_ID = :current_case_id AND
PETITION_DATE = (SELECT MAX(PETITION_DATE)
FROM CASE_INSTANCES
WHERE IN_INSTANCE_TYPE IN (1,8)
AND CA_CASE_ID = :current_case_id
AND ROWNUM < 2
) b
WHERE a.case_id = b.ca_case_id(+)
Regards
K.Rajkumar -
How do I join together arcs and lines in a single Shape???
I am out of my depth, I am probably missing something spectacular .... I need to construct a shape from arcs and lines to get something like this, only closed:
Like a winding river sort of thing... I do not need to draw this I need to have this shape and its area available to me.... How do I join these two arcs and two lines into a shape from which I can find - area.contains(xy.getX(), xy.getY()); , preatty please?
here is the code that causes numerous errors:
import java.awt.*;
import java.awt.Graphics.*;
import java.awt.Graphics2D.*;
import java.awt.geom.RectangularShape.*;
import java.awt.geom.Arc2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
class MyShapes //extends Arc2D
public static Arc2D outerOne;
public static Arc2D innerOne;
public static Line2D upLine, bottomLine;
public static Area area = new Area();
public MyShapes(double[] upper, double [] lower)
outerOne.setArc(upper[0], upper[1], upper[2], upper[3], upper[4], upper[5], (int)upper[6]);
// x, y, w, h, OA, AA, int OPEN =1
innerOne.setArc(lower[0], lower[1], lower[2], lower[3], lower[4], lower[5], (int)lower[6]);
//outerTR=this.makeClosedShape(outerTopRightArc,middleTopRightArc);
upLine = new Line2D.Double(outerOne.getX(),outerOne.getY(),innerOne.getX(),innerOne.getY());
bottomLine = new Line2D.Double(outerOne.getX()+outerOne.getWidth(),outerOne.getY()+outerOne.getHeight(),innerOne.getX()+innerOne.getWidth(),innerOne.getY()+innerOne.getHeight());
area = this.joinAll(outerOne,innerOne, upLine, bottomLine);
private Area joinAll(Arc2D out, Arc2D in, Line2D one, Line2D two)
GeneralPath joiner = new GeneralPath(out);
joiner.append(in, true);
joiner.append(one, true);
joiner.append(two, true);
Area temp = new Area(joiner);
return temp;
public boolean isInArea(Point xy)
return area.contains(xy.getX(), xy.getY());
public boolean isItClosed()
return area.isSingular();
ThanksGlad to hear you find what was wrong. Still, it doesn't the main problem : why is that method crashing?
Here is what I've done in the mean time. See if it fits your purpose.import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.*;
public class MyShapes {
private Arc2D outerOne;
private Arc2D innerOne;
private Shape line1;
private Shape line2;
public MyShapes(double[] upper, double[] lower) {
outerOne = new Arc2D.Double(upper[0],
upper[1],
upper[2],
upper[3],
upper[4],
upper[5],
0);
innerOne = new Arc2D.Double(lower[0],
lower[1],
lower[2],
lower[3],
lower[4],
lower[5],
0);
line1 = new Line2D.Double(outerOne.getStartPoint().getX(),
outerOne.getStartPoint().getY(),
innerOne.getStartPoint().getX(),
innerOne.getStartPoint().getY());
line2 = new Line2D.Double(outerOne.getEndPoint().getX(),
outerOne.getEndPoint().getY(),
innerOne.getEndPoint().getX(),
innerOne.getEndPoint().getY());
public void paint(Graphics2D aGraphics2D) {
aGraphics2D.draw(outerOne);
aGraphics2D.draw(innerOne);
aGraphics2D.draw(line1);
aGraphics2D.draw(line2);
public static void main(String[] args) {
double [] XO= {56, 58, 400, 280, 90, 90};// outter arc
double [] XI={114, 105, 300, 200, 90, 90}; // inner arc
final MyShapes myShapes = new MyShapes(XO, XI);
JPanel panel = new JPanel() {
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
myShapes.paint(g2);
final JFrame frame = new JFrame("Test shape");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.setContentPane(panel);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
frame.show();
} -
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 -
How can I join together a photo and a text (or other vector files)?
Hi all.
I'm trying to do a poster with a sort of graffiti writings on a wall but I can't reach for any kind of realism. I'd like to see the writing on the wall like it was actually written.
I'm using a real photo behind the writings but the image and the text don't connect together, it is simply like a copy-past work. I don't know if I was clear because English is not my first language.. the effect I'd like to reach is like if the writings were printed on the wall.. but the wall is a photo so I don't know if they can be joined together..Sounds like you are looking to make the writing realistic. That is better done in photoshop. Some tisp you can sue
use a blending mode on your writing so that it blends naturally into
If your wall is made of brick for example, you can save a grayscale imageg of your weall and use displace in photoshop to distort the writng so it looks liek it is follwoing a bump mapo of the grayscale imaeg you made
you can use a grayscale of your wall as a mask on your writing. Use a curve to brighten the mask, so most of the writing shows through, except for some edges and such you want to roughen up -
These two queries return same data?
select * from voucher where (unit = 'TIA4M' or unit = 'TIAFM' or unit = 'TIAWM' or unit = 'TIATW' or unit = 'TIAPA' )
and invoice_dt >= TO_DATE('01/01/2006', 'MM/DD/YYYY')
select * from voucher where unit in ('TIA4M', 'TIAFM', 'TIAWM', 'TIATW', 'TIAPA')
and invoice_dt >= TO_DATE('01/01/2007', 'MM/DD/YYYY')
Also the first is much faster right?The first query is using a date of Jan 1, 2006. The second query is using a date of Jan 1, 2007.
Assuming that is a typo, the two queries are semantically identical. Since Oracle can easily transform an IN-list to a series of OR's, though, I would doubt that there would be any performance difference between them absent the 2006/2007 change.
Justin -
Can these two queries be combined
Is there a more eloquent way of joining the two tales to only
get those records that have more than one record. Instead of
writing two seperated queries, can one query achieve the
results?Could this also have been solved with one query by just doing
the following?
<cfquery name="get_mult_posn" datasource="#dsn#">
SELECT a.posn_id, a.pers_id, a.job_titl, frst_name,
mid_name, last_name
FROM posntable a, perstable b
WHERE a.pers_id = b.pers_id
</cfquery> -
I am unable to uodate Pages and Numbers sice I changed my Apple ID, because I forgot my password and other security information. How I do I now update these applications. The system is asking for my Old Apple ID.
Also i am unable to activitate icloud. I did not receive a verication email. How can this issue be addressed?
Regards,
P.S. my email address is [email protected]https://iforgot.apple.com/cgi-bin/WebObjects/DSiForgot.woa/wa/iforgot?app_type=e xt&app_id=93&returnURL=https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.wo a&language=US-EN
-
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
-
My itunes account wont let me download music
i am trying to download my music from my itunes purchased but showes a message that i cant download my music until 90 days. what can i do?
-
i have a backup and sychronizing program called Synk that is currently unscriptable. I want to set up folder action so that when i plug various drives in this program opens the correct backup files and the program. So far i have managed to get the pr
-
Unable to update the page name programmatically
Hi, I'm trying to change the Page title through the program. It seems, its updating but when I actually open the page and see the page it is not showing the updated page title. Here is the code IPcdObjectFactory pcdObjectFactory = ((IPcdGlS
-
Customization of Tabs in Central Office
Hi, I am a first time poster on the forum. I have a question about modifying tabs in Central Office. If I want to add a tab or remove a tab in Central Office is there documentation available that can assist me with that process or some helpful knowle
-
Compiling at DOS prompt?
When compiling at the DOS prompt one gets an error because one can only use 3 letter extensions unlike what is needed for "javac simple.java" and "java simple.class"