Join help with Tablet
As you can see on the queries below I'm a complete newbie to SQL. But hoping someone can help. I have 3 request each return a number grouped under the name of "deposit". What I want to achieve is to have a query that returns all 3 results in the 1 table.
Total count
SELECT
INS_STAGE.TA_AEVEN. LEV3 DID "deposit."
COUNT (DISTINCT INS_STAGE.TA_AEVEN. NUM_1) AS 'Total number of jobs '.
Of
INS_STAGE.TA_AEVEN
where
(
INS_STAGE.TA_AEVEN. AD_TS BETWEEN % ' 2014060001' AND ' 2014069999% '
AND INS_STAGE.TA_AEVEN. TYCOD NOT IN ('NOW', 'PLAN-OUT', 'POSSUM',
"CABLE_PI_INQUIRY")
)
GROUP BY
INS_STAGE.TA_AEVEN. LEV3;
Second count
SELECT
INS_STAGE.TA_AEVEN. As "Deposit," Lev3
COUNT (DISTINCT INS_STAGE.TA_AEVEN. NUM_1) as "closed by MT.
Of
INS_STAGE.TA_AEVEN
WHERE
INS_STAGE.TA_AEVEN. AD_TS BETWEEN 2014060001 ' %' AND ' 2014069999% '
AND INS_STAGE.TA_AEVEN. CURENT 'T ='
AND INS_STAGE.TA_AEVEN. XTERM as ' $%.
AND INS_STAGE.TA_AEVEN. TYCOD NOT IN ('NOW', 'PLAN-OUT', 'POSSUM',
"CABLE_PI_INQUIRY")
INS_STAGE.TA_AEVEN.lev3 group
Third Chief
SELECT
INS_STAGE.TA_AEVEN. LEV3 DID "deposit."
COUNT (DISTINCT INS_STAGE.TA_AEVEN. NUM_1) AS "not closed by MT.
Of
INS_STAGE.TA_AEVEN
WHERE
INS_STAGE.TA_AEVEN. AD_TS BETWEEN 2014060001 ' %' AND ' 2014069999% '
AND INS_STAGE.TA_AEVEN. CURENT 'T ='
AND INS_STAGE.TA_AEVEN. XTERM NOT LIKE ' $%.
AND INS_STAGE.TA_AEVEN. TYCOD NOT IN ('NOW', 'PLAN-OUT', 'POSSUM',
"CABLE_PI_INQUIRY")
GROUP BY
INS_STAGE.TA_AEVEN. LEV3
Hoping someone can help
See you soon
Buddy
Hey Buddy,
This should be easily possible as long as you account on the same table.
First find the filter which is the least restrictive of all three queries criteria.
It seems that your first query filter is usable. The filter itself seems that can be tuned a bit, but this is a different task and requires further analysis.
The grouping is also the same, which can also be used. In other cases you must break the grouping at the lowest level possible, and then follow the steps in the extra $.
The last and most important step is to change what is counted.
Additional filters should now be made as an expression inside the COUNT function. Remember that NULL values will not be taken into account, that's what we use.
Your final selection will probably look like this. I can't test it, since you provided no examples of scripts. But I'm sure you can eliminate syntax errors I made.
Select t.lev3
count (*) total_count
count (distinct t.num1) as total_jobs
, count (distinct case when t.current 't =' and t.xterm like ' $% ' then t.num1 end) as closed_by_MT
, count (distinct case when t.current 't =' and t.xterm not like ' $% ' then t.num1 end) as not_closed_by_MT
of ins_stage.ta_even t
where t.ad_ts between... and...
and t.tycod not in (...)
T.lev3 group;
BTW. The SEPARATE inside the County very often is not necessary. Compare the total_count with your total column column: jobs and see if there really is a difference. SEPARATE requires an additional sorting in general deteriorating performance.
Tags: Database
Similar Questions
-
Need help with the condition join in SQL
Hi all -
I need to ask for help with this query:
Create table user_tab_col_test (varchar2 (30) from table_name, column_name varchar2 (30), data_type varchar2 (30));
Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ('Column2', 'table1', 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ("Column3", 'table1', 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ('column4', 'table1', 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ("column1", "table2", 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column2', 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', "Column3", 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column4', 'varchar2')
Commit;
Create table all_cons_columns_test (varchar2 (30) from table_name, column_name varchar2 (30), constraint_name varchar2 (30))
Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ("table1", "column1", "primary")
Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ("table1", "column1", "secondary")
Commit;
This is my query and the current result:
Select u.table_name, u.column_name, c.constraint_name
Of user_tab_col_test u
Outer join all_cons_columns_test c left
On (u.table_name = c.table_name
AND U.COLUMN_NAME = C.COLUMN_NAME
AND C.CONSTRAINT_NAME IN ('main'))
order of U.table_name, U.COLUMN_NAME;
TABLE_NAME COLUMN_NAME, CONSTRAINT_NAME
------------------ --------------------- ----------------------------
Table1 primary Column1
Table1 Column2
Table 1 Column3
Table2 Column1
Table2 Column2
Three questions:
(1) I don't want to return results where table_name = "table1". I can't get this to work.
(2) is my proper request and this is the best way to return my desired results? For example, I want all of the columns of user_tab_col_test and I want to only display the constraint_name from all_cons_columns_test argument if the argument constraint_name = 'primary '.
(3) will be the synatx be the same if I need to join a third table to all_cons_columns_test?
Any advice/suggestions are appreciated-
John
Published by: user703358 on January 11, 2013 20:57
Published by: user703358 on January 11, 2013 21:48Hi, John,.
user703358 wrote:
Hi all -I need to ask for help with this query:
Create table user_tab_col_test (varchar2 (30) from table_name, column_name varchar2 (30), data_type varchar2 (30));
Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
Insert into user_tab_col_test (table_name, column_name, data_type) values ('Column2', 'table1', 'varchar2')...Thanks for posting the CREATE TABLE and INSERT.
It is more useful if you post the code that can be run without modification. You did not semicolons after INSERTION instructions.Three questions:
(1) I don't want to return results where table_name = "table1". I can't get this to work.What have you tried? Post your best attempt.
Here's one way:SELECT u.table_name , u.column_name , c.constraint_name FROM user_tab_col_test u LEFT OUTER JOIN all_cons_columns_test c ON u.table_name = c.table_name AND u.column_name = c.column_name AND c.constraint_name IN ('primary') WHERE u.table_name = 'table1' -- ***** NEW ***** ORDER BY u.table_name , u.column_name ;
You would not put this condition in the clause; who controls what is considered as a match between the tables, and "u LEFT OUTER JOIN c" means show all lines of u, even if they do not have a match in the c.
(2) is my proper request and this is the best way to return my desired results? For example, I want all of the columns of user_tab_col_test and I want to only display the constraint_name from all_cons_columns_test argument if the argument constraint_name = 'primary '.
Basically, this application is very well.
It displays all the columns of user_tab_col_test; missing data_type. Just add u.data_type to the SELECT clause, or change the SELECT clauseSELECT u.* , c.constraint_name
(3) will be the synatx be the same if I need to join a third table to all_cons_columns_test?
Do you mean "" * add * one-third * column * to all_cons_columns_test '? "
It depends on what results you want. Post new CREATE TABLE and INSERT and instructions the results you want new data.
Most likely, the basic structure of what you've written will remain exactly the same. -
Need help with the ANSI Join syntax
Version: 11.1.0.7
I have my select statement that returns 3000 lines and looks like
I want to convert it to ANSI SQL, because it must be able to Hibernate, and the developer says that Hibernate include only ANSI SQL. I tried something likeselect .. from tab1 a,tab2 b,tab3 c where a.c1=b.c1 and b.c2 = c.c2(+) and ... group by ..
I felt bad and it turned out to be the same. It returns no rows. Please help with the correct syntax.select .. from tab1 a INNER JOIN tab2 b ON a.c1=b.c1 LEFT OUTER JOIN tab3 c ON b.c2=c.c2 where ... group by ..
I'm not sure, sorry, because it's certainly the ANSI equivalent to the non-ANSI.
Would you have examples of queries and data that you can reproduce the problem with, and that we could analyze?
Published by: Seanmacgc on July 15, 2009 12:48
If there is no Clause WHERE conditions in the original that are included in the ANSI version of the query in the WHERE Clause for the EXTERNAL table itself joined, then that could transform the JOIN JOIN internally, that is, all the filters on the EXTERNAL joined table should be included in the JOIN predicate - IT (b.c2 = c.2 AND c.c3 = 'X').
-
How can blackBerry smartphones, I get my calendar information on my curve of sinc with Tablet
I don't have email on my phone and I only have the basics. I thought that once I created the bridge of blackberry in my calendar on my curve would automatically transfer/sinc with my tablet. Thank you for your help with this.
I figured it thanks... I'm new the all the technology and the tablet...
-
Hello. Need help with my layout sensitive, using straight lines only html5 and css3 that I can understand and explain a novice level please - without any restart. Desktop and mobile are in a single html doc. The desktop version is 'ok '.
Try to match these mobile Office layouts
On the mobile version:
-Impossible to get the buttons nav blocks, vertical text button Align, and align the image of the product (square pictures) to the Center. (margin: auto; does not work)
I used heights in the header because I'll have code for desktop, mobile and tablet in the CSS so it changes (and do not know how to support better). Also need to Add a link to the logo image background in header.
Thanks in advance!
TheOriginal150mph wrote:
Hello. Need help with my layout sensitive, using straight lines only html5 and css3 that I can understand and explain a novice level please - without any restart. Desktop and mobile are in a single html doc. The desktop version is 'ok '.
Try to match thesemobile Officelayouts
On the mobile version:
-Impossible to get the buttons nav blocks, vertical text button Align, and align the image of the product (square pictures) to the Center. (margin: auto; does not work)
Commenting on just a habit of property changing the css if you have defined it for the desktop version. Your nav elements are not vertically Center because you have a bottom padding set on them for the office, there are only changes for mobile in your css media query.
.main-nav a {}
display: block;
text-decoration: none;
/ * padding-bottom: 15px; */
Padding: 12px 0;
}
Change the properties for the .product-images for mobile boxes: you have float attached to them for the desktop version and which cascade down to the mobile version, unless you change in the media query:
.product-image {}
float: none;
Width: 50%;
margin: 0 auto 20px auto;
}
As I mentioned in one of my posts related to your project, you will probably have to make your product images a bit larger. They fill the area once they form a column to width of 768px screen or you could resist transform them to one column until a little more by using a media query extra set at a narrow screen width to evoke this action
-
Illustrator draw android app says that it requires 4.3. I have a viking RCA pro 10.1 which is 5.0, but it says that my device is not compatible. Can anyone help with this?
HI JBlessed,
What is a Tablet? Because the draw is not yet supported on Android tablets.
Sue.
-
Hi all
I've been loving learning PowerCLI.
I have problems, adding information to a script I had help with. I have problems with the eastern line,
Add-Member - InputObject $reportedvm - MemberType noteProperty-name GuestOs - value $VM. Guest.OSFullName
I'll add the entire script bellows. If someone could explain to me what I am doing wrong. I get just white that colum in my CSV. I guess that the $VM variable does not have property info I'm looking for. I don't know if I have to do a join or something else to get this info.
Here's the script as a whole.
$reportedvms = New-Object System.Collections.ArrayList
$vms = get-view - viewtype virtualmachine. Tri-objet-property {$_.} Config.Hardware.Device | where {$_-is [VMware.Vim.VirtualEthernetCard]} | Measure-object | {Select - ExpandProperty County}-descending
{foreach ($vm to $vms)
$reportedvm = new-Object PSObject
Add-Member - Inputobject $reportedvm - MemberType noteProperty-Guest name-value $vm. Name
Add-Member - InputObject $reportedvm - MemberType noteProperty-name-value of $($vm.) UUID Config.Uuid)
Add-Member - InputObject $reportedvm - MemberType noteProperty-name GuestOs - value $VM. Guest.OSFullName
Add-Member - InputObject $reportedvm - MemberType noteProperty-name ToolsVersion-value $VM. Config.Tools.ToolsVersion
Add-Member - InputObject $reportedvm - MemberType noteProperty-name ToolsUpdate - value $VM. Guest.ToolsStatus
$networkcards = $vm.guest.net
$i = 0
{foreach ($ntwkcard to $networkcards)
Add-Member - InputObject $reportedvm - MemberType NoteProperty-Name "card$ {i}." Network"- value $ntwkcard.Network
Add-Member - InputObject $reportedvm - MemberType NoteProperty-Name "card$ {i}." IpAddress"- value of $($ntwkcard.) IpAddress |? {$_ - like "*."} * »})
$i ++
}
$reportedvms.add ($reportedvm) | Out-Null
}
$reportedvms | Export-Csv C:\temp\vm_nic_report.csvTry
$VM. Guest.guestFullName
instead.
You're recovery VirtualMachine objects.
-
I'm trying to follow some RTF data to a language specification... I have installation test record this follow-up. I am able to find in spec summary test specifications and the specific information I'm looking for in the HTMLData table. What I can't find is the join track to return to the wording PKID of HTMLData. Can I get help with the PL - SQL Query?
The data schema says EP HTMLdata doesn't have all the relationships, but there is a PKID PLM4P referenced in the FKPARENT column, which starts by "2220" which takes me to the richtextsupportingdocuments table. Schema docs say that this table has no relationship either. However richtextsupportingdocuments table has a FKspec column that refers to an object beginning with '5818' and that takes me to gsmFormulationSteps. gsmFormulationSteps titles back to FormulationInput that does not have a formula PKID/FKID of '5618' but rather '1004' for materials, etc... so that's where I'm stuck... I am moving back to the spec formualution ID and not been followed correctly of the 5816 PKID.
Could someone help me get back on track with the data track? Thank you.Good question - the configuration of database for formulating specifications is a little different from other specifications (since you can have snapshots of a language specification). So it is not that simple. You need to join DWBSpecificationRoots and fkWorkingVersionParent of dwbSpecifications column, as below
SELECT ss. SpecID, ss. SpecNumber, as follows. StepName, html. HtmlContent
OF specsummary ss
INNER JOIN DWBSpecificationRoots t2 ON ss.specid = t2.fkOwner
INNER JOIN t3 ON t2.pkid = t3.fkWorkingVersionParent dwbSpecifications
Steps to INNER JOIN gsmFormulationSteps t3.pkid = steps.fkParent
inner join richTextSupportingDoc on richText.fkSpec = steps.pkid richText
HtmlData html on html.fkParent = richText.pkid inner join
where
SS. SpecID = -
I would like to know where I can get help about to reinstall Photoshop CS3. I bought Photoshop a long time ago when he was on a disc. I continued the upgrade it until I had upgraded to CS3. Recently my computer crashed which had Photoshop CS3 top. I try to get the Photoshop CS3 on my new computer, but he wants the serial number of the original program, but it DOES NOT list the photoshop 3 and photoshop 4 that I bougt garage years. I joined Photoshop CS3, so it should be placed on the record that I admit. Can anyone tell me where I can get help with this. CS3 cost me a lot of money and I like to use.
You might be out of luck because Adobe no longer provides support for CS3. The only hope you have is to contact the Support from Adobe by chat or phone and explain your scenario and hope that you get someone who is willing to work a little bit and see what they can do to help you through.
Here is a link to a page with options to help make contact:
http://www.Adobe.com/support/download-install/supportinfo/
If all else fails, you can try after the path of the user in the following thread 9 response to see if someone can help... http://forums.Adobe.com/thread/1443854?TSTART=0
-
Where clause ' where 1 = 1 ' help with SQL tuning
Hello Tuning specialists,.
It is useful to use ' where 1 = 1 ' and then type all joins and conditions in the statements 'AND' of the SQL when writing SQL queries. I would like to know if it helps with the writing queirs this way SQL query performance.
Thanks in advance.
Published by: oracle_developer on October 8, 2012 10:41oracle_developer wrote:
Hello Tuning specialists,.
It is useful to use ' where 1 = 1 ' and then type all joins and joins in the statements "AND" when writing SQL queries.
I would like to know if it helps with the writing queirs this way SQL query performance.He has No. performance impact.
It is done when building dynamic SQL, so each sentence can start with AND -
Hello
Use: Oracle 11.2.0.1 on Windows XP
create table tab40 (bno varchar2 (1), pno varchar2 (7), the number (3) weight, lineno number (3));
insert into tab40 values ('1', '1115027', 36, 1);
insert into tab40 values ('2', the '1115100', 25, 2);
insert into tab40 values ('3', the '1115200', 50, 3);
insert into tab40 values ('1', the '1112510', 60, 4);
insert into tab40 values ('+', '1112610', 6, 5)
insert into tab40 values ('+', '1112710', 4, 6);
insert into tab40 values ('+', '1110710', 1, 7)
insert into tab40 values ('2', '1117014', 79, 8);
insert into tab40 values ('+', '1117000', 9, 9)
insert into tab40 values ('+', '1117001', 2, 10);
insert into tab40 values ('1', '1317001', 200, 11);
insert into tab40 values ('1', '1697001', 20, 12);
insert into tab40 values ('2', '2997001', 40, 13);
insert into tab40 values ('1', '2996001', 44, 14);
create table tab41 (bno varchar2 (1), pno varchar2 (7), the number (3) weight, lineno number (3));SQL> select * from tab40; B PNO WEIGHT LINENO - ------- ---------- ---------- 1 1115027 36 1 2 1115100 25 2 3 1115200 50 3 1 1112510 60 4 + 1112610 6 5 + 1112710 4 6 + 1110710 1 7 2 1117014 79 8 + 1117000 9 9 + 1117001 2 10 1 1317001 200 11 B PNO WEIGHT LINENO - ------- ---------- ---------- 1 1697001 20 12 2 2997001 40 13 1 2996001 44 14 14 rows selected. SQL>
insert into tab41 values ('1', '1115027', 36, 1);
insert into tab41 values ('2', the '1115100', 25, 2);
insert into tab41 values ('3', the '1115200', 50, 3);
insert into tab41 values ('1', the '1112510', 60, 4);
insert into tab41 values ('+', '1112610', 6, 5)
insert into tab41 values ('+', '1110710', 1, 6);
insert into tab41 values ('2', '1117014', 79, 7);
insert into tab41 values ('+', '1117000', 9, 8)
insert into tab41 values ('1', '1317001', 200, 9);
insert into tab41 values ('1', the '1697001', 20, 10);
insert into tab41 values ('2', '2997001', 40, 11);
insert into tab41 values ('1', '2996001', 44, 12);
insert into tab41 values ('+', '1112710', 4, 13);
insert into tab41 values ('+', '3332710', 8, 14)
Power required:SQL> select * from tab41; B PNO WEIGHT LINENO - ------- ---------- ---------- 1 1115027 36 1 2 1115100 25 2 3 1115200 50 3 1 1112510 60 4 + 1112610 6 5 + 1110710 1 6 2 1117014 79 7 + 1117000 9 8 1 1317001 200 9 1 1697001 20 10 2 2997001 40 11 B PNO WEIGHT LINENO - ------- ---------- ---------- 1 2996001 44 12 + 1112710 4 13 + 3332710 8 14 14 rows selected. SQL>
Logic: The plus sign in Bno says that no. Packet was sent to the customer with the last packet (order by lineno) either signed number that is for example in tab40 there is line no. 6 whose main package number is 1112510 (from either signed lines previous PNO). So come to the power required; which shows that these signed (whose master PNO is that) packages are not according to the tab40 vs tab41 something as complete an outer join between tab40 and tab41. Example:A B C D E F G H 1 1112510 60 4 1 2996001 44 12 + 1112710 4 6 + 1112710 4 13 2 1117014 79 8 + 1117001 2 10 1 2996001 44 12 + 3332710 8 14
+ 1112710 is associated with 1112510 in tab40, in tab41, it is associated with 2996001; So that's the difference.
+ 1117001 is associated with 1117014 in tab40, while it is not in tab41.
Vice versa;
+ 3332710 is associated with 2996001 in tab41, while it is not in tab40.
I mean, if only more marked parcel number of PNO line mater is not equal to master PNO (previous no more BNO) in both the table, it should be part of the select query please. Usually this happens when our packing service gets a late delivery of prior master package, so that they send just the small package with immediately available (either) a package.
Kindly let me know; I am clear in my request, or I should elaborate more. This can be more complex, because may be bad/data from the design table, but I need the output of the select query please help me.
Full Outer Join help please
Wrongly, I posted the question here, I should post here. Keep will be remembered in the future.
Kindly help me.
Thank you and best regards.
Published by: user12050217 on January 3, 2012 08:38Hello
user12050217 wrote:
HelloUse: Oracle 11.2.0.1 on Windows XP
create table tab40 (bno varchar2 (1), pno varchar2 (7), the number (3) weight, lineno number (3));
insert into tab40 values ('1', '1115027', 36, 1); ...Thanks for posting the version and CREATE TABLE and INSERT statements. It is very useful.
Power required:
A B C D E F G H 1 1112510 60 4 1 2996001 44 12 + 1112710 4 6 + 1112710 4 13 2 1117014 79 8 + 1117001 2 10 1 2996001 44 12 + 3332710 8 14
Those are the best names of columns for this work? Even if your users really insist on having the names, do not forget that people who want to help are also familiar with your application, so it would be useful that you used for the column names more descriptive as bno_40 (meaning tab40 bno), pno_40,..., lineno_41 during the validation of the problem. You can change the column alias back to a, b,..., h after the problem is resolved, if necessary.
Logic: The plus sign in Bno says that no. Packet was sent to the customer with the last packet (order by lineno) either signed number that is for example in tab40 there is line no. 6 whose main package number is 1112510 (from either signed lines previous PNO). So come to the power required; which shows that these signed (whose master PNO is that) packages are not according to the tab40 vs tab41 something as complete an outer join between tab40 and tab41. Example:
+ 1112710 is associated with 1112510 in tab40, in tab41, it is associated with 2996001; So that's the difference.
+ 1117001 is associated with 1117014 in tab40, while it is not in tab41.
Vice versa;
+ 3332710 is associated with 2996001 in tab41, while it is not in tab40.I mean, if only more marked parcel number of PNO line mater is not equal to master PNO (previous no more BNO) in both the table, it should be part of the select query please. Usually this happens when our packing service gets a late delivery of prior master package, so that they send just the small package with immediately available (either) a package.
Kindly let me know; I am clear in my request, or I should elaborate more. This can be more complex, because may be bad/data from the design table, but I need the output of the select query please help me.
Yes, it seems unnecessarily complicated, so you should be especially clear in your description.
It is always useful to describe what each line of output. In this issue, it seems that different production lines represent different things:
(1) some lines represent an incompatibility between -marked lines in tab40 and tab41 (i.e. the lines or table where bno ='' and when the ofn even in the table has a different master_pno, or it the pno even does not exist in the other table). We will call these lines 'follower '.
(2) the other lines represent lines masters of the lines do not match (1)To get the master for each line + marked row in a table, use the analytical LAST_VALUE function. That's what the two first of subqueries, got_master_pno_40 and got_master_pno_41 below.
To get the lines are not (the disciples, or the output type (1)), do an outer join complete, as you said. It's that the subquery follows, mismatched_followers.
To get the final result, a Union of the followers with their respective masters. It's that the main request below.WITH got_master_pno_40 AS ( SELECT bno, pno, weight, lineno , LAST_VALUE ( CASE WHEN bno != '+' THEN pno END IGNORE NULLS ) OVER ( ORDER BY lineno) AS master_pno FROM tab40 ) , got_master_pno_41 AS ( SELECT bno, pno, weight, lineno , LAST_VALUE ( CASE WHEN bno != '+' THEN pno END IGNORE NULLS ) OVER (ORDER BY lineno) AS master_pno FROM tab41 ) , mismatched_followers AS ( SELECT NVL (m40.pno, m41.pno) AS pno , m40.bno AS bno_40 , m40.pno AS pno_40 , m40.weight AS weight_40 , m40.lineno AS lineno_40 , m40.master_pno AS master_pno_40 , m41.bno AS bno_41 , m41.pno AS pno_41 , m41.weight AS weight_41 , m41.lineno AS lineno_41 , m41.master_pno AS master_pno_41 FROM got_master_pno_40 m40 FULL OUTER JOIN got_master_pno_41 m41 ON m40.pno = m41.pno WHERE NVL (m40.master_pno, '?') != NVL (m41.master_pno, '?') AND '+' IN (m40.bno, m41.bno) ) SELECT bno_40, pno_40, weight_40, lineno_40 , bno_41, pno_41, weight_41, lineno_41 , pno , 'F' AS master_or_follower FROM mismatched_followers -- UNION ALL -- SELECT t40.bno, t40.pno, t40.weight, t40.lineno , t41.bno, t41.pno, t41.weight, t41.lineno , f.pno , 'M' AS master_or_follower FROM mismatched_followers f LEFT OUTER JOIN tab40 t40 ON f.master_pno_40 = t40.pno LEFT OUTER JOIN tab41 t41 ON f.master_pno_41 = t41.pno -- ORDER BY pno , master_or_follower DESC ;
This assumes that ofn is unique to each table and that ofn! = ' ?'.
Output:
B PNO_40 WEIGHT_40 LINENO_40 B PNO_41 WEIGHT_41 LINENO_41 PNO M - ------- ---------- ---------- - ------- ---------- ---------- ------- - 1 1112510 60 4 1 2996001 44 12 1112710 M + 1112710 4 6 + 1112710 4 13 1112710 F 2 1117014 79 8 1117001 M + 1117001 2 10 1117001 F 1 2996001 44 12 3332710 M + 3332710 8 14 3332710 F
You did not ask the last two columns, but you need to sort. If you don't want to see them, then you can make the UNION in a subquery, then, in the main query, use "ORDER BY pno, master_or_follower", as above, but do not include the columns in the SELECT clause. Your front end may have an easier way to hide these columns, so that they are still as a result set (and therefore, can be used in the ORDER byclause of a UNION) but are not displayed. In SQL * Plus, for example:
COLUMN pno NOPRINT COLUMN master_or_follower NOPRINT
-
looking for help with this query. can't do things.
4 tables.
doc_master
doc_folder_master
project_master
doc_relations
quick overview of tables
doc_master has all the documents in the files
doc_folder_master has all the names of folders (documents are in folders)
project_master has all the names of project
doc_relations has the relationship between records and documents by file ID and ID of Document.
try to get all the documents of the doc_master where the project name is '% provider %' I can do it without problem.
Like this...
Select * from document_master where proj_id IN
(select proj_id from project_master where status = 'A' and upper (proj_title) like '% PROVIDER %')
but now I must also name the folder in each document.
Try like this, but does not.
get the same name documents
Select doc_file_name, name, proj_title from)
Select * from
(select * from document_master where proj_id IN)
(select proj_id from project_master where status = 'A' and upper (proj_title) like '% PROVIDER %')
),
(select * from document_relations) b.
(select * from doc_folder_master) c,.
(select * from project_master) d
where a.doc_id = b.child_doc_id
and d.proj_id = a.proj_id
)
I apologize if I am missing any info. If you need more please let me know.
Published by: Jay on November 18, 2010 05:26So if I understand you
select a.doc_file_name, c.name, d.proj_title from document_master a, document_relations b, doc_folder_master c, project_master d where c.doc_folder_id = b.parent_doc_id and b.child_doc_id = a.doc_id and d.proj_id= a.proj_id and d.status='A' and upper(d.proj_title) like '%SUPPLIER%'
If every relationship exists, the query will work.
If not try an outer join to find the error asselect a.doc_file_name, c.name, d.proj_title from document_master a, document_relations b, doc_folder_master c, project_master d where c.doc_folder_id(+) = b.parent_doc_id and b.child_doc_id(+) = a.doc_id and d.proj_id(+) = a.proj_id
-
Help with the situation where a simple group by statement does not work
There is a table with two columns, which is memo (varchar2), another is recording_date (date). This table is used to recode an every day event. Right now, I need to know how many events registered each day during the time period (between any of the given day and any given end day). the result by selecting should have two columns the numeration of the event, the recording_date. chances are one day it is not just any event, in this situation there not all inserted rows so far here, but the result by selecting must contain also that day with the column count is set to zero.
Can anyone help with this? Thank you in advance!between 2010-4-5 and 2010-4-8 Count recording_date 2 2010-4-5 0 2010-4-6 1 2010-4-7 9 2010-4-8
Kind regards!Hello
See if this helps:I create a dummy cursor that contains one row for each day of the last year - I then outer join the result of the query against the log_table.
Here are my RAW file
Select * from log_data07/05/2010 1, TEST
TEST 2 05/05/2010
02/05/2010 3, TEST
30/04/2010 4, TEST
TEST OF 5 30/04/2010
30/04/2010 6, TEST
7-30/04/2010 TEST
8 TEST 06/05/2010
9 TEST 06/05/2010
10 06/05/2010 TEST
11 06/05/2010 TEST
06/05/2010 12, TEST
13 TEST 06/05/2010
2010-05-06 14, TEST
15 06/05/2010 TEST
16 06/05/2010 TEST
2010-05-06 17, TESTAnd here's the query
with date_ranger as (select trunc (sysdate-) level datecol
from dual connect by level<= 365="">=>
RAW_DATA as)
Select recording_date, count (*) numrows in log_data
Group of recording_date)
Select datecol, date_ranger numrows, raw_data
where = date_ranger.datecol raw_data.recording_date (+)
and datecol sysdate-10-sysdate
order by 1And the result
1 28/04/2010
2 29/04/2010
30/04/2010 3, 4
4 01/05/2010
02/05/2010 5, 1
6 03/05/2010
7 04/05/2010
8 05/05/2010 1
9 06/05/10/2010What you want?
See you soon,.
Harry -
Mulltiple criteria on the same column - please help with query
Could someone help with this query?
I have three tables-
Table: SuperOxMap
-------------
ox_id
ox_pd
Table: SuperCPDtls
------------
ox_pd
ox_dtid
Table: SuperPkDtls
------------
ox_dtid
ox_pkVal
Example of SuperPkDtls-
-------------
ox_dtid ox_pkVal
1 T1
2 T2
3 T3
As seen above, SuperOxMap.ox_pd = SuperCPDtls.ox_pd and SuperCPDtls.ox_dtid = SuperPkDtls.ox_dtid.
I find list of the SuperOxMap.ox_id and the SuperPkDtls.ox_pkVal where pkVal for this ox_id contains T1 and T2, but excludes the T3.
If I put in my join query IN ("T1", "T2") and! = 'T3', which obviously do not work. I don't know how / if I can use the inner query so that he can give me all the ox_ids where associated pkVal contains T1 and T2 but would not T3 contain.
You will appreciate all help!
-
need help with the Update statement
Hello
I received a question in a course and I tried my best to respond, and now my brain is giving. I would really appreciate help with the update statement. I don't mind if you do not validate a solution, a little nudge in the right direction would be really useful. I'll post that I got.
THE QUESTION
/ * For these agents disabled on more than seven missions, change their date of deactivation of the first date of deactivation of all the agents that have been activated in the same year as the agent that you update currently.
*/
I have it divided into parts, here is my select statement to agents disabled on more than 7 missions, which produces the deactivation_dates in the agents table that I want to update...
.. .and the code for the first date of deactivation for each year of activation agentSELECT s.deactivation_date FROM ( SELECT a.deactivation_date, count(m.mission_id) as nomissions FROM agents a INNER JOIN missions_agents m on a.agent_id=m.agent_id GROUP BY a.deactivation_date ) s WHERE s.nomissions>7 AND s.deactivation_date IS NOT NULL
..... I am not real to marry these two statements together in the Update statement. I can't extract each date of deactivation produced in the first select statement and their match against the first date of deactivation in the year they have been activated for the second select statement.select a2.deactivation_date from agents a2 where a2.deactivation_date= ( select min(a.deactivation_date) from agents a where to_number(to_char(a.activation_date,'YYYY'))=to_number(to_char(a2.activation_date,'YYYY')) )
Any help greatly appreciated... :))I began to wonder how things would :)
user8695469 wrote:
First of all why he chooses the date the earliest of all agentsUPDATE AGENTS_COPY AC /* (1) */ SET DEACTIVATION_DATE = ( SELECT MIN(AGS.DEACTIVATION_DATE) FROM AGENTS_COPY AGS , AGENTS_COPY AC /* (2) */ WHERE TRUNC(AGS.ACTIVATION_DATE,'YEAR') = TRUNC(AC.ACTIVATION_DATE,'YEAR') /* (3) */ )
He recovers as soon as the subquery has not been correctly set in the SET clause. It seems you are trying to update a correlated, but we are still having a conceptual shift. I have added a few comments to your code above and below will explain.
(1): when you do a correlated update it is useful to the table alias that you did right here.
(2): this table statement is not necessary and is the reason why the FIRST deactivation date is selected. The alias that you use (3) refers to THIS table, not the one defined in the update statement. Remove the line indicated by (2) in the FROM clause and a correlated update will happen.
and secondly why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
user8695469 wrote: then why is it to update each row, when I thought that I'm just the lines where the agents are disabled and missions > 7? Pointers on where I'm wrong would be very appreciated. (SQL = stupid query language!) :)
WHERE EXISTS ( SELECT a.agent_id, count(m.mission_id) FROM agents a /* INNER JOIN AC ON AC.AGENT_ID = A.AGENT_ID */ INNER JOIN missions_agents m ON a.agent_id=m.agent_id GROUP BY a.agent_id, a.deactivation_date HAVING count(m.mission_id)>7 AND a.deactivation_date IS NOT NULL )
Once again this problem is similar to the question above that a correlation update doesn't work. Test existence of lines in an EXISTS subquery. Since your subquery is not related to the table that you are trying to update, it will be always return a line and, therefore, it returns true for EACH LINE in the AGENTS table. To limit the game to only agents > 7 missions results, you need to add a join condition that references the table in your update statement. I added one above (with comments) as a sample.
I recommend you look over all material that you have associated with correlated subqueries, including documents that I posted above. This seems to be what you're having the problem more with. If you need me to explain the concept of correlated queries any better please let me know.
Thank you!
Maybe you are looking for
-
How can I access the ActiveX settings?
When you try to use a program downloaded on my desktop, you receive the following error message. How can I fix it?Sorry, your browser ActiveX settings prevent detection Laser App
-
This is my result. My IPad saying activation server is temporarily unavailable because the last OS download. Help, please!
-
How do to the tool bar remove delta search
I am running xp home and have lost control of my browser, search delta appear to have hung my tools and directing me to softango whenever I type in my field of research, and it seems that he has my best bloced bing and msn I downloaded with ie8.
-
WINDOWS 7 32-BIT updates as of yet have not installed from Windows Update. -------------------------------------------------------------------------- When you try to do a system restore it returns an error 0 x 80042318 (Volume Shadow Copy Services er
-
Internal error during the installation of DirectX for the user final web runtime install
Hi all I was browsing the forums and reading the discussions that relate to my question. Unfortunately, each of the solutions that I found do not seem to solve my specific problem. I recently got a new laptop (Dell E6540) and thought I'd try world o