Help with Joining a few tables
I need a help using JOINS. I plan to create ONE VIEW by bringing in all fields from First and Second table and a few chosen columns from Third, Fourth and Fifth tables. I have put to together below select statement which appears to be working syntax-wise but not efficient and may have dupes.
Table1 - RPT_APRL_PRODUCT with key field KEY_MATERIAL (KEY_MATERIAL = DIVISION||PLAN_CTRY||MKT_TYP_ID||MATERIAL)
Table 2 - RPT_FWEQ_PRODUCT with key field KEY_MATERIAL (KEY_MATERIAL = DIVISION||PLAN_CTRY||MATERIAL)
Table 3 - NSC_PROD_CIMG has a Key Field = MATERIAL_NBR
Table 4- STAGE#EMEA_NSAP.NSC_PROD_REG_CIMG has the Key field MATERIAL_NBR, REG_ID
Table 5 - STAGE#EMEA_NSAP.NSC_PROD_REG_CYC_CIMG has Key Fields MATERIAL_NBR, REG_ID, CYC_ID and ORGVERSIONID
Columns needed from Table 3 -- B.DIVISION, B.DIVISIONNAME, B.SUBLABEL, B.SUBLABELNAME and B.DEVELOPMENTREGION.
Columns needed from Table 4 --- C.GLOBALSOURCEINDICATOR
Columns needed from Table 5--- D.CARRYOVERFLAG
SELECT statement:
SELECT /*+ parallel (a,5) parallel (NET,5) */
a.key_material,
a.mkt_typ_id,
a.region_id,
CASE
WHEN a.region_id = '3' THEN 'USA'
WHEN a.region_id = '4' THEN 'EMEA'
WHEN a.region_id = '7' THEN 'CANADA'
END AS region_desc,
a.mkt_reg_cd,
CASE
WHEN a.mkt_reg_cd = '01' THEN 'USA'
WHEN a.mkt_reg_cd = '02' THEN 'EMEA'
WHEN a.mkt_reg_cd = '05' THEN 'AMER'
END AS mkt_reg_desc,
a.cat_bus_cd1,
a.cat_bus_desc1,
a.cat_bus_cd2,
a.cat_bus_desc2,
a.cat_bus_cd3,
a.cat_bus_desc3,
a.cat_bus_cd4,
a.cat_bus_desc4,
a.mkstr_cd,
a.mkt_clsfn_desc,
a.mkt_clsfn_cd1,
a.mkt_clsfn1_desc,
a.mkt_clsfn_cd2,
a.mkt_clsfn2_desc,
a.mkt_clsfn_cd3,
a.mkt_clsfn3_desc,
a.exp_sty_ind,
a.silh_cd,
a.silh_desc,
a.whlsl_prc,
0,
NULL,
NULL,
NULL,
NULL,
NULL,
a.gender_age_class_id,
a.gender_age_desc,
a.sports_activity_class_id,
a.sports_act_cls_desc,
a.gblcatsummcode,
a.gblcatsummdesc,
a.gblcatcorefocuscode,
a.gblcatcorefocusdesc,
a.segment,
a.segmentname,
a.l4l_fl,
NET.DIVISION,
NET.DIVISIONNAME,
NET.SUBLABEL,
NET.SUBLABELNAME,
NET.DEVELOPMENTREGION,
NULL,
NULL,
NULL,
NET.globalsourceindicator,
NET.CARRYOVERFLAG,
a.zz_chng_tmst,
a.zz_update_tmst,
a.zz_insert_tmst
FROM RPT_APRL_PRODUCT A,
(SELECT
APRL.DIVISION||APRL.PLAN_CTRY||APRL.MKT_TYP_ID||APRL.MATERIAL ; AS KEY_MATERIAL,
B.DIVISION,
B.DIVISIONNAME,
B.SUBLABEL,
B.SUBLABELNAME,
B.DEVELOPMENTREGION,
C.GLOBALSOURCEINDICATOR,
D.CARRYOVERFLAG
from RPT_APRL_PRODUCTAPRL,
NSC_PROD_CIMG B,
NSC_PROD_REG_CIMG C,
NSC_PROD_REG_CYC_CIMG D
where APRL.MATERIAL = B.MATERIAL_NBR AND
APRL.MATERIAL = C.MATERIAL_NBR AND
APRL.MATERIAL = D.MATERIAL_NBR AND
C.REG_ID = D.REG_ID) NET
WHERE A.KEY_MATERIAL = NET.KEY_MATERIAL(+)
Thanks for help in advance.
I have 4 tables and these are some sample data for
RPT_APRL_PRODUCT - Key Field = KEY_MATERIAL (this is a combination of plan_ctry,division,mkt_typ_id and material)
Sample data
KEY_MATERIAL PLAN_CTRY DIVISION MKT_TYP_ID MATERIAL
10PART1136353-010 PART 10 1 136353-010
10AMER1136353-010 AMER 10 1 136353-010
10USA1136353-010 USA 10 1 136353-010
10CANA1136353-010 CANA 10 1 136353-010
10PART1137508-050 PART 10 1 137508-050
10AMER1137508-050 AMER 10 1 137508-050
10CANA1137508-050 CANA 10 1 137508-050
10USA1137508-050 USA 10 1 137508-050
10PART1137617-050 PART 10 1 137617-050
10AMER1137617-050 AMER 10 1 137617-050nsc_prod_reg_cimg - keys (material_nbr and reg_id)
MATERIAL REG_ID GLOBALSOURCEINDICATOR
136353-010 3 G
136353-010 6 G
136353-010 7
137508-050 3
137508-050 6 G
137508-050 7
137508-050 46 G
137617-050 3
137617-050 6
137617-050 46 nsc_prod_reg_cyc_cimg - key is material_nbr, cyc_id, reg_id and orgversion_id
MATERIAL_NBR CYC_ID orgversion_id reg_ID CARRYOVERFLAG
136353-010 101 1 3 Y
136353-010 101 1 6 Y
136353-010 101 1 7 N
137508-050 202 1 3 Y
137508-050 202 1 6 N
137508-050 202 1 7
137617-050 205 1 3
137617-050 205 1 6
185204-402 181 1 8
185204-402 182 1 8 nsc_prod_cimg - key is material_nbr
MATERIAL_NBR SUBLABEL SUBLABELNAME
136353-010
137508-050 GD Good
137617-050
185204-402
185204-402
185204-402 BE Better
185204-402
185204-402
185204-402 CO Core
185204-402 BS BestWhat I intend to do, is to create one view by joining these four tables. The columns key_material, plan_ctry, division and MKT_TYP_ID come from RPT_APRL_PRODUCT. I need to join these tables in such a way that I bring in the other 1 or 2 columns each from the 3 tables as described above. The result should have a unique key_material and have the other column data in the view as well.
Result should be all the columns described above, something like this below...
KEY_MATERIAL PLAN_CTRY DIVISION MKT_TYP_ID MATERIAL SUBLABELNAME CARRYover_FL
10PART1136353-010 PART 10 1 136353-010
10AMER1136353-010 AMER 10 1 136353-010
Similar Messages
-
Newbie: help with join in a select query
Hi: I need some help with creating a select statement.
I have two tables t1 (fields: id, time, cost, t2id) and t2 (fields: id, time, cost). t2id from t1 is the primary key in t2. I want a single select statement to list all time and cost from both t1 and t2. I think I need to use join but can't seem to figure it out even after going through some tutorials.
Thanks in advance.
Rayt1 has following records
pkid, time, cost,product
1,123456,34,801
2,123457,20,802
3,345678,40,801
t2 has the following records
id,productid,time,cost
1,801,4356789,12
2,801,4356790,1
3,802,9845679,100
4,801,9345614,12
I want a query that will print following from t1 (time and cost for records that have product=801)
123456,34
345678,40
followed by following from t2 (time and cost for records that have productid=801)
4356789,12
4356790,1
9345614,12
Is this possible?
Thanks
ray -
All,
How to join inv.mtl_category_sets_tl and ibe.msites_b. I am having trouble to find which tables i need to join these two tables
I am not getting right mini site id for the caterogy set name
Your help is highly appreciated
Regards
Edited by: 792011 on Sep 12, 2011 12:49 PM792011 wrote:
Hi Bravid,
11110 is the site_id for ABC Catalog and same thing for 11111 DEF Catalog. These two are different websites
RegardsOkay so why do you have an entry for 11110 DEF and an entry for 11111 ABC in your source data? Where in your source data is there anything that identifies 11110 as site ABC - i.e. is there another attribute here or are you just planning to hard code it?
David -
Hi,
I have following 2 tables
CREATE TABLE a
sr_no INT
CREATE TABLE b
sr_no INT,
startdate DATE,
remark VARCHAR2(30)
One to many mapping relationship exists between the two tables.
for each sr_no in table a ther exists multiple/no record in table b.
If there are multiple entries in table b for a single entry in table a,
then i want remark data which is corresponding to minimum of the startdate in table b
Example data of table b
1 10/15/2009 one
1 10/29/2009 one1
2 10/28/2009 two
3 10/27/2009 three
4 10/26/2009 four
minimum date of the first 2 records is 10/15/2009.so i want remark as "one" when i join the 2 tables.
How do we achieve that ?Something like this?
SELECT SUB.SR_NO
, SUB.STARTDATE
, B.REMARK
FROM
SELECT SR_NO
, MIN(STARTDATE) AS STARTDATE
FROM B
GROUP BY SR_NO
) SUB
JOIN B ON B.SR_NO = SUB.SR_NO AND B.STARTDATE = SUB.STARTDATEThat is one possibility. There are many, many ways to achieve this kind of result. -
Help with joining one table to several
I have the following table
MSELECT
Res_ID
Res_type
34
501
56
501
72
501
81
502
90
502
100
502
47
503
48
503
The RES_ID will link to different tables such as tablea, tableb or tablec based on the RES_Type value .g. RES_Type ID 501 will link to tableA and 502 will link to TableB and 503 will link to TableC.
I have created the following query:
Select * from MSSELECT MSEL
Inner join tablea ta on
Ta.id = MSEL.ID and
Res_type = 501
Inner join tableb tb on
Tb.id = MSEL.ID and
Res_type = 501
If I run the following query then results are returned.
Select * from MSSELECT MSEL
Inner join tablea ta on
Ta.id = MSEL.ID and
Res_type = 501
However if I run the following query it is returning no results:
Select * from MSSELECT MSEL
Inner join tablea ta on
Ta.id = MSEL.ID and
Res_type = 501
Inner join tableb tb on
Tb.id = MSEL.ID and
Res_type = 501Try:
Select * from MSSELECT MSEL
LEFT OUTER join tablea ta on
Ta.id = MSEL.ID and
Res_type = 501
LEFT OUTER join tableb tb on
Tb.id = MSEL.ID and
Res_type = 501
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered. -
hello can some one help me in joining the tables
po_vendors of AP and gl_je_headers or gl_he_headers of GL
thankyouHow about this:
Build first an auxiliary table (you can truncate it every time) and in it:
create table auxtab as
select distinct employeeid, row_date from table1
union
select distinct employeeid, row_date from table2
union
select distinct employeeid, row_date from table3
union
Then you can use this "auxiliar" table as the driving one for outer joins
select * from auxtab left outer join table1 on ()
left outer join table2 on ()
left outer join table3 on ()
etc.. -
Extract each entry from BSEG for BELNRs in BKPF-BELNR,
and KOSTL in ZTABLE-KOSTL.
sum(DMBTR) by KOSTL into
internal tab <ITAB (fields KOSTL, DMBTR)>.
i wrote the code like this:
Select sum( aDMBTR ) aKOSTL into inkostltotal from BSEG as a
inner join BKPF as b on bBELNR = aBELNR
inner join Ztable as c on c~KOSTL = a-KOSTL
group by a~KOSTL.
it was giving error:
You cannot use comparisons with column column references in pool and
cluster tables: "A~BELNR". column references in pool and cluster
tables: "A~BELNR". column references in pool and cluster tables:
"ABELNR". column tables: "ABELNR".
i need to use select, sum, group by to solve this can some one
help me with this.hi saritha,
y ur not using for all entries, that will best in this situation.
use for all entries like that
CLEAR : T_EQUZ,T_EQUZ[].
SELECT * FROM EQUZ INTO TABLE T_EQUZ
WHERE DATBI = '99991231'.
IF NOT T_EQUZ[] IS INITIAL.
select J_3GBELNRI equnr J_3GEMPFAE into
corresponding fields of table
T_J_3GBELP from J_3GBELP
FOR ALL ENTRIES IN T_EQUZ
where j_3guposnr ne '1'
and J_3GEMPFAE in Reciver
and equnr = T_EQUZ-EQUNR.
regards
vijay dwivedi
rewards if usefull -
OBIEE 11G help with report narrative and table view
Hi,
I have a report designed like the below, I have used "narrative view" for customer detail and "table view" for order detail. In the narrative view I can say row = 1 and it picks up the first record of the customer detail, but order detail shows all rows. How can I control it so the order detail shows only the detail record of the customer associated. Also how do I go to the second record and so forth. Please help. If this is not possible and if there are any alternates, please let me know. Thanks for your time and help.
Customer Number:
Customer Name:
Customer Address:
Order Detail:
Line number | Order No | Order description | Order Statusssk1974 wrote:
Hi,
I have a report designed like the below, I have used "narrative view" for customer detail and "table view" for order detail. In the narrative view I can say row = 1 and it picks up the first record of the customer detail, but order detail shows all rows. How can I control it so the order detail shows only the detail record of the customer associated. Also how do I go to the second record and so forth. Please help. If this is not possible and if there are any alternates, please let me know. Thanks for your time and help.
Customer Number:
Customer Name:
Customer Address:
Order Detail:
Line number | Order No | Order description | Order StatusWhy don't you do this?
1) Build a dashboard prompt for Customer Number. and save to a PV.
2) Build a report with all the columns for customer and order (in Criteria View) with a filter for the PV to capture the dashboard prompt.
3) Build a pivot table with Customer Number and Customer Name in the Rows section. Put the Customer Address in the Measures section and change the Aggregation Rule to Max.
This will serve as the summary table showing only the information of the customer selected.
2) Build Pivot Table:2 with the Order details.
3) In the Compound Layout, put Pivot table one on the top and Pivot Table:2 below it.
When a customer is selected, you will have the customer data with the order details under it for that customer only. -
Help with vendor email Address table
Can someone help me with this issue.
I am trying to pull out the vendor email address for all the vendors. Vendor email address are the one's which are entered in the First page on XK01. I checked on the table name and it brings up only a structure.
Please helpYou can try something like this....
Example...
*Selecting the ADRNE from LFA1...
SELECT SINGLE ADRNR FROM LFA1 INTO I_ADRNR
WHERE LIFNR = ITAB-LIFNR.
*Passing ADRNR to ADR6 to get Email...
SELECT SMTP_ADDR INTO TABLE I_Z1EMAIL
FROM ADR6 WHERE ADDRNUMBER = I_ADRNR. -
Hello Experts,
I am struggling with a problem.
In my development I have two db tables for eg. Table A and Table B.
Now table A has about 200,000 entries and table B has about 800,000 entries.
I want to delete all the extra entries (junk entries-not present in A but present in B) from table B on the basis of one field that is common between them
i.e. All the entries for whom 'A-field NE B-field'
Now i tried using internal tables but the loop execution is taking forever.
And I tried using a Select query for all entries:
SELECT *
FROM B
INTO TABLE itab_B
FOR ALL ENTRIES IN itab_A
WHERE field EQ itab_A-field.
This query gives me the records which are present in both tables.
But if I try to change the 'where' condition to 'NE' it does not work.
Is there any join statement to meet my requirement?
Thanks in Advance
OmkarHi Omkar,
reduce the internal table to the fields you really need to identify, the key fields and the fields of interest. Use field-symbols for loops. make one of the two tables a hashed table with unique key.
You will observe a performance enhancement of factor 100 at least.
If you had given more information or even a piece of code, I may have done the coding for you.
Regards,
Clemens -
Help with creating a custom table cell editor?
hi, i was reading up on various tutorials and trying to write codes that pops up a simple calendar when clicked on text of the Date class in a table, so far, i can't seem to get my classes working.. the following is some classes i've written for this task (note, there are alot of commented out lines, those are the modifications done to the tutorial classes in http://java.sun.com/docs/books/tutorial/)
any help would be appreciated :D
thanks in advance!
What i have done so far:
/** BASIC TABLE CLASS FOR DEMONSTRATION*/
//import java.awt.*;
import java.util.*;
import javax.swing.*;
public class TableBasic extends JFrame
public TableBasic()
String[] columnNames = { "Date", "String", "Integer", "Boolean" };
Object[][] data =
{ { new Date(), "A", new Integer(1), Boolean.TRUE },
{new Date(), "B", new Integer(2), Boolean.FALSE },
{new Date(), "C", new Integer(9), Boolean.TRUE },
{new Date(), "D", new Integer(4), Boolean.FALSE}
JTable table = new JTable(data, columnNames)
//Returning the Class of each column will allow different
//renderers to be used based on Class
public Class getColumnClass(int column)
return getValueAt(0, column).getClass();
table.setDefaultRenderer(Date.class, new CalendarRenderer(true));
table.setDefaultEditor(Date.class, new CalendarEditor());
table.setPreferredScrollableViewportSize(table.getPreferredSize());
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add(scrollPane);
public static void main(String[] args)
TableBasic frame = new TableBasic();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
//frame.setLocationRelativeTo(null);
frame.setVisible(true);
* CLASS BASED ON ColorRenderer.java at http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/ColorRenderer.java
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.Border;
import javax.swing.table.TableCellRenderer;
//import java.awt.Color;
import java.awt.Component;
public class CalendarRenderer
extends JLabel
implements TableCellRenderer
Border unselectedBorder = null;
Border selectedBorder = null;
boolean isBordered = true;
public CalendarRenderer(boolean isBordered)
this.isBordered = isBordered; setOpaque(true);
//MUST do this for background to show up.
public Component getTableCellRendererComponent(JTable table,
Object color,
boolean isSelected,
boolean hasFocus,
int row,
int column)
String newDate = (String)color;
setText(newDate);
if (isBordered)
if (isSelected)
if (selectedBorder == null)
selectedBorder = BorderFactory.createMatteBorder(2,5,2,5, table.getSelectionBackground());
setBorder(selectedBorder);
else
if (unselectedBorder == null)
unselectedBorder = BorderFactory.createMatteBorder(2,5,2,5, table.getBackground());
setBorder(unselectedBorder);
//setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
return this;
* the editor based on ColorEditor.java at http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/ColorEditor.java
import javax.swing.AbstractCellEditor;
import javax.swing.table.TableCellEditor;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JTable;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ColorEditor
extends AbstractCellEditor
implements TableCellEditor, ActionListener
Color currentColor;
JButton button;
JColorChooser colorChooser;
JDialog dialog;
protected static final String EDIT = "edit";
public ColorEditor()
//Set up the editor (from the table's point of view),
//which is a button.
//This button brings up the color chooser dialog,
//which is the editor from the user's point of view.
button = new JButton();
button.setActionCommand(EDIT);
button.addActionListener(this);
button.setBorderPainted(false);
//Set up the dialog that the button brings up.
colorChooser = new JColorChooser();
dialog = JColorChooser.createDialog(button,
"Pick a Color",
true, //modal
colorChooser,
this, //OK button handler
null); //no CANCEL button handler
* Handles events from the editor button and from
* the dialog's OK button.
public void actionPerformed(ActionEvent e)
if (EDIT.equals(e.getActionCommand()))
//The user has clicked the cell, so
//bring up the dialog.
button.setBackground(currentColor);
colorChooser.setColor(currentColor);
dialog.setVisible(true); //Make the renderer reappear.
fireEditingStopped();
else
//User pressed dialog's "OK" button.
currentColor = colorChooser.getColor();
//Implement the one CellEditor method that AbstractCellEditor doesn't.
public Object getCellEditorValue()
return currentColor;
//Implement the one method defined by TableCellEditor.
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
currentColor = (Color)value; return button;
/** THE SIMPLE CALENDAR WRITTEN TALIORED TO WORK WITH DIALOGS*/
import javax.swing.*;
import java.util.Calendar;
import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
//import java.beans.*; //property change stuff
public class CalendarDialog
extends JDialog
//implements PropertyChangeListener
private JButton[] btn = new JButton[49];
private int month = Calendar.getInstance().get(Calendar.MONTH);
private int year = Calendar.getInstance().get(Calendar.YEAR);
private JLabel lbl = new JLabel("", JLabel.CENTER);
private JOptionPane optionPane;
private String curDate = null;
private JTextArea output = new JTextArea(curDate, 1, 20);
private String btnString1 = "Enter";
private String btnString2 = "Cancel";
public CalendarDialog()
//super(aFrame, true);
setContentPane(buildGUI());
setDates();
public JPanel buildGUI()
JPanel panel = new JPanel();
String[] header = { "Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" };
JPanel midPanel = new JPanel(new GridLayout(7, 7));
for (int x = 0; x < btn.length; x++)
final int selection = x;
btn[x] = new JButton();
btn[x].setFocusPainted(false);
if (x < 7)
JLabel lbl = new JLabel(header[x], JLabel.CENTER);
lbl.setFont(new Font("Lucida", Font.PLAIN, 10));
midPanel.add(lbl);
else
btn[x].addActionListener(new ActionListener()
public void actionPerformed(ActionEvent ae)
displayDatePicked(btn[selection].getActionCommand());
midPanel.add(btn[x]);
JPanel lowPanel = new JPanel(new GridLayout(1, 3));
JButton prevBtn = new JButton("<< Previous");
prevBtn.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent ae)
month--;
setDates();
lowPanel.add(prevBtn);
lowPanel.add(lbl);
lowPanel.add(output);
JButton nextBtn = new JButton("Next >>");
nextBtn.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent ae)
month++;
setDates();
lowPanel.add(nextBtn);
JPanel outputPanel = new JPanel();
Object[] options = { btnString1, btnString2 };
optionPane =
new JOptionPane(
output,
JOptionPane.QUESTION_MESSAGE,
JOptionPane.YES_NO_OPTION,
null,
options,
options[0]);
outputPanel.add(optionPane);
panel.setLayout(new BorderLayout());
panel.add(lowPanel, BorderLayout.NORTH);
panel.add(midPanel, BorderLayout.CENTER);
panel.add(outputPanel, BorderLayout.SOUTH);
return panel;
public void setDates()
for (int x = 7; x < btn.length; x++)
btn[x].setText("");
SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy");
Calendar cal = Calendar.getInstance();
cal.set(year, month, 1);
int dayOfWeek = cal.get(java.util.Calendar.DAY_OF_WEEK);
int daysInMonth = cal.getActualMaximum(java.util.Calendar.DAY_OF_MONTH);
for (int x = 6 + dayOfWeek, day = 1; day <= daysInMonth; x++, day++)
btn[x].setText("" + day);
lbl.setText(sdf.format(cal.getTime()));
public void displayDatePicked(String day)
if (day.equals("") == false)
SimpleDateFormat sdf = new SimpleDateFormat("EEEE d MMMM, yyyy");
Calendar cal = Calendar.getInstance();
cal.set(year, month, Integer.parseInt(day));
curDate = sdf.format(cal.getTime());
//JOptionPane.showMessageDialog(this, "You picked " + sdf.format(cal.getTime()));
output.setText(sdf.format(cal.getTime()));
public String getDate()
return curDate;
public void setDate(String date)
curDate = date;
}well, i have indeed narrowed down my problem after some digging around.. one thing i discovered that i don't need CalendarRenderer.java.. and i found out i don't really know what does
//Implement the one method defined by TableCellEditor.
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
curDate = (String)value; return button;
}do, as it seems to be the problem:
java.lang.ClassCastException
at CalendarEditor.getTableCellEditorComponent(CalendarEditor.java:78)
at javax.swing.JTable.prepareEditor(JTable.java:3786)
at javax.swing.JTable.editCellAt(JTable.java:2531)
at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.adjustFocusAndSelection(BasicTableUI.java:510)
at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.mousePressed(BasicTableUI.java:494)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5097)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3195)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
mmm.. does anyone know what i should modify for that to work? -
Hi,
I am not sure if I am doing something wrong here, but would appreciate if someone point out my mistake.
I have two table item and item_status
item_status do not contain all the items but only the ones which have specific status
Question(1):
select count(*) from item
and
select count(*) from item left join item_status on item.itemid = item_status.item_id
Result of these two queries dont match. Can you'll plz help me understand it.
Question(2):
I want count of items from table item by location (location is another field in table item) but I want to exclude items which have status lost in the item_status table.
This is the query I used:
select location, count(*) from item left join item_status on item.itemid = item_status.item_id where item_status.status = 'lost'
is this the correct way, coz when I tried the figures where way to low,
Thanks,
RajaHi, Raja,
Raja Gopalan wrote:
Hi,
I am not sure if I am doing something wrong here, but would appreciate if someone point out my mistake.
I have two table item and item_status
item_status do not contain all the items but only the ones which have specific status
Question(1):
select count(*) from item
and
select count(*) from item left join item_status on item.itemid = item_status.item_id
Result of these two queries dont match. Can you'll plz help me understand it.If there can be many rows in item_status that all match the same row in item, then the 2nd query will have a higher COUNT than the first.
If you'd post your tables, I could show you in detail.
Since you didn't I'll use tables from the scott schema.
SELECT d.deptno
FROM scott.dept d;produces 4 rows:
. DEPTNO
10
20
30
40Only 3 of these rows have a match in the mep table, but the ones that match have many matches.
SELECT d.deptno
, e.ename
FROM scott.dept d
LEFT OUTER JOIN scott.emp e ON d.deptno = e.deptno;produces 15 rows
. DEPTNO ENAME
20 SMITH
30 ALLEN
30 WARD
20 JONES
30 MARTIN
30 BLAKE
10 CLARK
20 SCOTT
10 KING
30 TURNER
20 ADAMS
30 JAMES
20 FORD
10 MILLER
401 row for each row in emp that has a match in dept (that is all 14 rows in emp) plus 1 row for every row in dept that does not have a match in emp (1 row).
Question(2):
I want count of items from table item by location (location is another field in table item) but I want to exclude items which have status lost in the item_status table.
This is the query I used:
select location, count(*) from item left join item_status on item.itemid = item_status.item_id where item_status.status = 'lost'
is this the correct way, coz when I tried the figures where way to low,If you want a count by location, then you should say "GROUP BY location".
You probably need a sub-query to check for 'lost'. Without seeing your tables and data, I can't be sure.
Maybe something like
SELECT location
, COUNT (*)
FROM item
WHERE itemid NOT IN ( -- Begin subquery to find bad item_ids
SELECT item_id
FROM item_status
WHERE status = 'lost'
) -- End subquery to find bad item_ids
GROUP BY location
; -
Left join query with join of three tables
I'm trying to build a query which has me stumped. Most of the query is fairly straightforward but I've run into an issue I'm not sure how to solve.
Background:
We have actions stored in i_action.
We have the available attributes for each type of action. The available attributes for each action are described in shared_action_attribute. Each type of action may have up to three attributes or none at all.
We have the values stored for the attributes in i_attribute_value.
A written example:
We have a transfer action (action_code B4). The entry of the B4 action into i_action records the fact that the transfer occurred and the date on which it occurred. The available attributes for a transfer action are the receiving function code, the receiving unit number, and the transfer reason code. These available attribute types and their order are stored in shared_action_attribute. The actual values of the attributes for a specific transfer action are stored in i_attribute_value.
Now i_action and i_attribute_value can be directly linked through action_seq in i_action and ia_action_seq in i_attribute_value. A left join built between these two tables provides results for all actions (including actions which have no attributes) and attribute values (see query 1 below).
There are two issues. First, I only want the first two attributes. In order to specify the first two attributes, I also have to link i_attribute_value to shared_action_attribute (which is where the order is stored). I can build a simple query (without the left join) linking the three tables but then actions with no attributes would be excluded from my result set (see query 2 below).
The second issue is that I would actually like one row returned for each action with first_attribute and second_attribute as columns instead of two rows.
The final query will be used to create a materialized view.
Here are the tables and examples of what's stored in them:
TABLE i_action
Name Type
ACTION_SEQ NUMBER(10)
ACTION_DATE DATE
ACTION_CODE VARCHAR2(3)
DELETED VARCHAR2(1)
EXAMPLE ROWS
ACTION_SEQ ACTION_DATE ACTION_CODE DELETED
45765668 09-OCT-09 B2 A
45765670 09-OCT-09 BA A
45765672 09-OCT-09 B6 A
45765673 09-OCT-09 B4 A
45765674 09-OCT-09 G1 A
45765675 09-OCT-09 M3 A
TABLE i_attribute_value
Name Type
IA_ACTION_SEQ NUMBER(10)
SACTATT_SACT_CODE VARCHAR2(3)
SACTATT_SAT_TYPE VARCHAR2(3)
VALUE VARCHAR2(50)
EXAMPLE ROWS
IA_ACTION_SEQ SACTATT_SACT_CODE SACTATT_SAT_TYPE VALUE
45765668 B2 ACO 37B
45765670 BA ROA D
45765670 BA ROR P
45765672 B6 CAT C
45765673 B4 RFC E
45765673 B4 TRC P
45765673 B4 RUN 7
45765674 G1 SS 23567
45765674 G1 ASG W
TABLE shared_action_attribute
Name Type
SACT_CODE VARCHAR2(3)
SAT_TYPE VARCHAR2(3)
ORDER NUMBER(2)
TITLE VARCHAR2(60)
EXAMPLE ROWS
SACT_CODE SAT_TYPE ORDER TITLE
B2 ACO 1 Office code
BA ROR 1 Reason for reopen
BA ROA 2 Reopen authority
B6 CAT 1 Category
B4 RFC 1 Receiving function code
B4 RUN 2 Receiving unit code
B4 TRC 3 Transfer reason code
G1 SS 1 Staff sequence
G1 ASG 2 Assignment reason
QUERY 1:
This is my current query along with its results. Most of it is straightforward select but one column is populated using the last_value analytical function (thanks to you guys). The last column in the below view stores the attribute value. What I want is to replace that single column with two columns named first_attribute and second_attribute and to eliminate any other attributes.
SELECT ia.action_seq, ia.action_date, ia.action_code cod,
NVL
(LAST_VALUE (CASE
WHEN ia.action_code = 'G1'
AND iav.sactatt_sat_type = 'SS'
THEN VALUE
WHEN ia.action_code IN ('A0', 'A1')
THEN '67089'
END IGNORE NULLS
) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
ia.serial_number, ia.action_seq),
'67089'
) staff_seq,
value
FROM i_action ia LEFT JOIN i_attribute_value iav
ON iav.ia_action_seq = ia.action_seq
WHERE ia.deleted = 'A';
ACTION_SEQ ACTION_DA COD STAFF_SEQ VALUE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 D
45765670 09-OCT-09 BA 67089 P
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E
45765673 09-OCT-09 B4 67089 P
45765673 09-OCT-09 B4 67089 7
45765674 09-OCT-09 G1 23567 23567
45765674 09-OCT-09 G1 23567 W
45765675 09-OCT-09 M3 23567
QUERY 2:
This query limits to the first two attributes but it also drops actions which have no attributes and it still creates multiple rows for each action instead of a single row with two columns for the attributes.
SELECT ia.action_seq, ia.action_date, ia.action_code cod,
NVL
(LAST_VALUE (CASE
WHEN ia.action_code = 'G1'
AND iav.sactatt_sat_type = 'SS'
THEN VALUE
WHEN ia.action_code IN ('A0', 'A1')
THEN '67089'
END IGNORE NULLS
) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
ia.serial_number, ia.action_seq),
'67089'
) staff_seq,
value
FROM shared_action_attribute saa, ims_action ia, ims_attribute_value iav
WHERE iav.ia_action_seq = ia.action_seq
AND iav.sactatt_sact_code = saa.sact_code
AND iav.sactatt_sat_type = saa.sat_type
AND saa.display_order IN ('1','2')
AND ia.deleted = 'A';
ACTION_SEQ ACTION_DA COD VALUE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 D
45765670 09-OCT-09 BA 67089 P
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E
45765673 09-OCT-09 B4 67089 7
45765674 09-OCT-09 G1 23567 23567
45765674 09-OCT-09 G1 23567 W
I found this pretty complex to try to write out - I hope I've been clear.
Thanks so much!Ok, here's more information with a simplified question. I figured out the syntax for building my query with the three tables. My final query returns multiple rows (multiple attributes per action). Instead of multiple rows, I'd like two columns (first_attribute, and second_attribute) in a single row (I only need the first two attributes).
Here's the action table:
CREATE TABLE I_ACTION
ACTION_SEQ NUMBER(10) NOT NULL,
ACTION_DATE DATE,
ACTION_CODE VARCHAR2(3 BYTE) NOT NULL,
DELETED VARCHAR2(1 BYTE),
);With the following rows added:
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765668, '09-oct-2009', 'B2', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765670, '09-oct-2009', 'BA', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765672, '09-oct-2009', 'B6', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765673, '09-oct-2009', 'B4', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765674, '09-oct-2009', 'G1', 'A');
Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
Values (45765675, '09-oct-2009', 'M3', 'A');
COMMIT;The attribute table is:
CREATE TABLE I_ATTRIBUTE_VALUE
IA_ACTION_SEQ NUMBER(10) NOT NULL,
SACTATT_SACT_CODE VARCHAR2(3 BYTE) NOT NULL,
SACTATT_SAT_TYPE VARCHAR2(3 BYTE) NOT NULL,
VALUE VARCHAR2(50 BYTE),
);With the following rows:
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765668, 'B2', 'ACO', '37B');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765670, 'BA', 'ROR', 'P');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765670, 'BA', 'ROA', 'D');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765672, 'B6', 'CAT', 'C');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765673, 'B4', 'RFC', 'E');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765673, 'B4', 'RUN', '7');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765673, 'B4', 'TRC', 'P');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765674, 'G1', 'SS', '23567');
Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
Values (45765674, 'G1', 'ASG', 'W');
COMMIT;And finally, the shared table:
CREATE TABLE SHARED_ACTION_ATTRIBUTE
SACT_CODE VARCHAR2(3 BYTE) NOT NULL,
SAT_TYPE VARCHAR2(3 BYTE) NOT NULL,
TITLE VARCHAR2(25 BYTE) NOT NULL,
DISPLAY_ORDER NUMBER(2) NOT NULL
);With the following rows:
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B4', 'RFC', 'Y', 'Rcv. Function Code', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B6', 'CAT', 'Y', 'Category', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('G1', 'SS', 'Y', 'Staff Name', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B2', 'ACO', 'Y', '"Other" Office Code', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B4', 'RUN', 'Y', 'Receiving Unit Number', 2);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B6', 'LEP', 'N', 'LEP Issue/Sub Category', 2);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B4', 'TRC', 'Y', 'Transfer Reason Code', 3);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B6', 'NEP', 'N', 'NEP Issue', 3);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('G1', 'ASG', 'Y', 'Assignment Reason', 2);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('B2', 'MSN', 'S', 'Machine Serial Number', 3);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('BA', 'ROR', 'Y', 'Reopen Reason', 1);
Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
Values ('BA', 'ROA', 'Y', 'Reopen Authority', 2);
COMMIT;Now, this is my current query (it's changed from my first post):
SELECT ia.action_seq, ia.ici_charge_inquiry_seq, ia.action_date,
ia.serial_number, ia.reporting_office, ia.reporting_function,
ia.reporting_unit, ia.action_code, ia.machine_serial_number,
NVL
(LAST_VALUE (CASE
WHEN ia.action_code = 'G1'
THEN VALUE
WHEN ia.action_code IN ('A0', 'A1')
THEN '67089'
END IGNORE NULLS
) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
ia.serial_number, ia.action_seq),
'67089'
) staff_seq,
(CASE
WHEN display_order = '1'
THEN VALUE
END) first_attribute,
(CASE
WHEN display_order = '2'
THEN VALUE
END) second_attribute
FROM ims_action ia
LEFT JOIN ims_attribute_value iav
ON iav.ia_action_seq = ia.action_seq
LEFT JOIN shared_action_attribute
ON sactatt_sact_code = sact_code
AND sactatt_sat_type = sat_type
WHERE ia.deleted = 'A';Which gives me the following results:
ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 D
45765670 09-OCT-09 BA 67089 P
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E
45765673 09-OCT-09 B4 67089 7
45765673 09-OCT-09 B4 67089
45765674 09-OCT-09 G1 23567 W
45765674 09-OCT-09 G1 23567 23567
45765675 09-OCT-09 M3 23567 The result I WANT is similar but I want the two separate attribute columns on one row as such:
ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE
45765668 09-OCT-09 B2 67089 37B
45765670 09-OCT-09 BA 67089 P D
45765672 09-OCT-09 B6 67089 C
45765673 09-OCT-09 B4 67089 E 7
45765674 09-OCT-09 G1 23567 23567 W
45765675 09-OCT-09 M3 23567 Thanks so much! -
Airport express vista:help with joining a protected or unprotected network
hello,
i've been trying to set up a network between my computer and the airport express, with no luck,
it works if i don't tell it to join my networks, but then i don't have internet access,
and when i'm connected to the internet, i can't get both of them to work,
any suggestions?
i just need the airport for music, not internet, but apparently, two routers can't use one wi-fi card, so that's why it needs to join an existing network, that's what i understood from the different posts,
i have unsecured, and secured connections available,(the unsecured network is faster so i'd like to use that one)
PS: i noticed that the airport used the ETHERNET mac address, don't know if that helps,
thank you in advance,
i'm running out of ideas,
NayPerform a "hard" reset of the AX
- (ref: http://docs.info.apple.com/article.html?artnum=108044)
Setup the AX
Connect your computer directly (using an Ethernet cable) to the Ethernet port of the AX, and then, using the AirPort Admin Utility check these settings:
AirPort tab
- Base Station Name: <whatever you wish or use the default>
- AirPort Network Name: <whatever you wish or use the default>
- Create a closed network (unchecked)
- Wireless Security: Not enabled
- Channel: Automatic
- Mode: 802.11b/g Compatible
Internet tab
- Connect Using: Ethernet
- Configure: Manually
- IP address: <provided by your university>
- Subnet mask: <provided by your university>
- Router address: <provided by your university>
- DNS servers: <provided by your university>
- WAN Ethernet Port: Automatic
Network tab
- Distribute IP addresses (unchecked) -
Help with Joining two SharePoint lists using LINQ
Hi Guys,
I have found many threads with this question. Although I had one doubt. I wanted to know that while performing a Join operation on two SharePoint Lists using LINQ does the column on which we are performing the join operation need to be a Lookup column?
I was initially using CAML but since my lists does not contain lookup columns I switched to LINQ but my doubt still remains.
I would really appreciate any help from you guys and also would appreciate if I could get some examples that I could refer to.
Thank youJoins in LINQ to SharePoint 2010
How to: Query Using LINQ to SharePoint
This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.
Maybe you are looking for
-
Flash problem after software update (on 10.6.8)
I'm having flash problems on *some* macs after one of the recent software updates (june 2012). On my school's 10 iMac's (2010), I can't play flash games anymore *in safari*. Chrome is ok. An example site, is http://www.barryfunenglish.com/games.php
-
When I moved from XP to Vista, it seems I've lost many fonts. I have installing them directly into the Common folder with no success. Any other ideas? I have less than 500 fonts.
-
I realise this is an OEM board for Medion, and Medion supplied the computer system to PCWorld, so the support must be done by PC World, and if you know them you realise my problem getting information. Anyway, there are 3 PCI slots, one blue amd two g
-
ViewObject & Horizontal ScrollBar
Hi All, I need to use 2 view object with the same number of column on a page jspx. I want to use only one horizontal scrollbar. How can I get the horizontal scrollbar position on one view and set the horizontal scrollbar position of the other one? In
-
Connecting to the db is taking too long with Shared Servers connection
Hi all OS: Solaris 11 SPARC 64 bits DB: 2-node RAC Oracle 11.2.0.3.5 After doing a migration of a 40GBs database from a 9i database to a 11g database, it's takin too long to connect to the db, which is using shared server. In the moment, there aren't