Input data match with two columns in a table
HelloI want to find records where the input data (> 100 records) are adapted to the two columns of the table
See below
with t as
(select 1 as id, 101 as num 'ram' that pat from dual
Union
Select 2 102, 'tom' from dual
Union
Select 1 103, 'tom1' from dual
Union
Select 2 101, 'tom2' from dual
Union
Select 2 104, 'tom3' from dual
Union
Select 1 105, 'tom1' from dual
Union
Select 2 105, 'tom1' from dual
)
Select * from t
I want to find records from the 't' table where (id, num) will be (1 101, 2 102, 1, 105)
Output must be
ID num
1 101
2 102
1 105
select *
from t
where (id, num) in (
(1,101),
(2,102),
(1,105)
);
Or store the input in a temporary table values and use IN
select *
from t
where (id, num) in (
select col1,col2
from your_temp_table
);
Published by: JAC on 20 may 2013 14:55
Tags: Database
Similar Questions
-
I want to put two tables on a page with two columns how can I do this?
I want to put two tables on a page with two columns how can I do this?
It depends on what application you are using.
If you use Word, then a good way would be to create a single table of 5 columns, check the borders of the invisible middle column so that it appears to be two separate tables. You will need to do the same thing for unused cells downstairs as well.
To get the best advice on Office-Word questions, use the forum not the Windows 7 Office forum that you do. Look at the top of this page, just below the logo MS Answers and click on Forums , then select desktop. Once there, you can select Word. By using the forum Office will give you a better chance to find a solution to your problem, as it is inhabited by people who know much about their topic. Search the Forum of office for the topic, then, if no notice is found, ask your question here instead of this.
-
Fill a table with two columns using a custom bean
Hello
Can you provide me or give me a link to an example of populating a table (with two columns) with a custom bean?
Thank you
TSPSHello..
I'm Jules Destrooper is what you wanthttp://download.Oracle.com/docs/CD/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html
Hopes, will help you
-
How to write a query for the data exchange between two columns?
How to write a query for the data exchange between two columns?
I tried a request, does NOT work.
Thank you.update tmp t1 set t1.m1=t1.m2 and t1.m2=(select t2.m1 from tmp t2 where t2.student_id = t1.student_id)
Published by: user533361 on October 23, 2009 14:04Just plain and simple:
update tmp t1 set t1.m1=t1.m2, t1.m2=t1.m1 /
SY.
-
Help to extract data Clob to a column in a table that has several lines in a table
Help to extract data Clob to a column in a table that has several lines in a table
It works for only the first line
CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';
Grant read, write on DIRECTORY XMLDIR to the public;
() dbms_xslprocessor.clob2file
beef in CLOB,
XMLDIR IN VARCHAR2,
"testfile2.txt" IN VARCHAR2);
DECLARE
buf CLOB.
BEGIN
SELECT H15_DOC
IN buf
OF H15TEST. H15_STAGE
where rownum = 1;
dbms_xslprocessor.clob2file (buf, 'XMLDIR', 'testfile2.txt');
END;
/
-This error code
CREATE or REPLACE DIRECTORY XMLDIR AS ' / orabackups';
Grant read, write on DIRECTORY XMLDIR to the public;
() dbms_xslprocessor.clob2file
XData in CLOB,
XMLDIR IN VARCHAR2,
"testfile2.txt" IN VARCHAR2,
CSID in NUMBER: = 0);
DECLARE
CURSOR xmlmycur IS SELECT H15_DOC
OF H15TEST. H15_STAGE
where rownum = 102140;
l_clob CLOB.
XData CLOB.
BEGIN
DBMS_LOB.CREATETEMPORARY (l_clob, true);
DBMS_LOB.CREATETEMPORARY (xdata, true);
OPEN xmlmycur.
LOOP
SEEK xmlmycur INTO xdata;
dbms_xslprocessor.clob2file (xdata, 'XMLDIR', 'testfile2.txt');
EXIT WHEN xmlmycur % notfound;
END LOOP;
CLOSE Xmlmycur;
END;
/
ORA-21560: 3 argument is null, invalid or out of range
ORA-06512: at "SYS." DBMS_LOB", line 991
ORA-06512: at "XDB". DBMS_XSLPROCESSOR', line 324
ORA-06512: at line 15 level
FYI, it seems that the file being created will exceed 5 gig
Yes, it is a known issue with DBMS_XSLPROCESSOR.clob2file with big files.
Here is a slightly modified version of the code that I posted earlier, fixing WRITE_ERROR except:
DECLARE
v_file utl_file.file_type;
-write a unique to clob
procedure write_clob (p_content in clob) is
v_buffer varchar2 (32767).
V_POSITION pls_integer: = 1;
v_amount pls_integer: = 32767;
Start
loop
Start
DBMS_LOB. Read (p_content, v_amount, v_position, v_buffer);
exception
When no_data_found then exit;
end;
UTL_FILE.put_raw (v_file, utl_raw.cast_to_raw (v_buffer), true);
V_POSITION: = v_position + v_amount;
end loop;
end;
BEGIN
-Open the file
v_file: = utl_file.fopen ('TEST_DIR', 'testfile2.txt', 'wb', 32767);
-loops through the lines
for r in)
Select h15_doc
of h15test.h15_stage
)
loop
write_clob (r.h15_doc);
end loop;
UTL_FILE.fclose (v_file);
END;
/
-
Oracle how to multiply two columns of different tables and results
Oracle how to multiply two columns of different tables and get the result in the third column?
I want to multiply all the lines of the quantinty column in the table of quantity with the relevant lines of the table of prices price column and get the result of multiplying in the third column. What should I use procedure trigerr? OR IS IT POSSIBLE HOW TO DO IT PLEASE HELP :D
Edited by: 994229 2013-03-15 12:44/* Formatted on 3/15/2013 3:51:08 PM (QP5 v5.185.11230.41888) */ CREATE TABLE mytable1 AS (SELECT 1 id, 5 VALUE FROM DUAL UNION ALL SELECT 2, 7 FROM DUAL UNION ALL SELECT 3, 8 FROM DUAL); CREATE TABLE mytable2 AS (SELECT 1 id, 4 VALUE FROM DUAL UNION ALL SELECT 2, 12 FROM DUAL UNION ALL SELECT 10, 12 FROM DUAL); SELECT id, mytable1.VALUE, mytable2.VALUE, mytable1.VALUE * mytable2.VALUE product FROM mytable1 FULL OUTER JOIN mytable2 USING (id) ORDER BY id;
ID VALUE VALUE_1 PRODUCT 1 5 4 20 2 7 12 84 3 8 10 12
-
How to recover the data type of a column in a table?
Hello
I want to retrieve the data type of a column in a table. At the moment I'm querying attribute 'OCI_ATTR_DATA_TYPE', but it is SQLT_CHR varchar2 and nvarchar2 data type columns. I need to make a distinction between these columns of two separate data types. Y at - it all API through which I could get the exact data type of a column, i.e. "nvarchar2?
Thanks in advance.
HashimHello
It is not a very direct way to do it. What you can do is to call OCIDescribeAny on the table that you want to get information. You can then get the OCI_ATTR_CHARSET_FORM attribute for the column. If the value of the attribute that you get is SQLCS_IMPLICIT, that would mean its a varchar/char/varchar2 column regular. If you get SQLCS_NCHAR, this means that the column is NCHAR. You can get the example of it here:
http://download.Oracle.com/docs/CD/B14117_01/AppDev.101/b10779/oci06des.htm#446491
Just look for the section "Recovering for a Table column Datatypes".
Thank you
Sumit -
How can I find what is the data type of a column of a Table in oracle or SQL?
(a) what happens if I want to know the type of data in a specific column in the Table.
(b) how to find the column data types?
Can someone help me please. I am new to oracle and try to learn a few tricks
Hello
How to do
SQL > desc
SQL> desc emp Name Null? Type ----------------------------------------- -------- ---------------------------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2)
-
Number of matches between two columns
Column1 Column2 5 5 5 2 5 5 4 3 4 4 Football match 3 I basically you want to compare two columns and count matches in the corresponding lines. I tried using the following formula:
SUMPRODUCT (--($column1=$column2))
... but it doesn't work! Any suggestion?
Tiago,
It seems you are trying to use array formulas (maybe since excel?) who do not work in number.
Here's how I would solve this problem:
Make sure that the table where data is named 'Data' (as shown, or change the table name references to match your table name)
Add a new column (C)
C2 = AND (A2 = B2, A2≠ "")
It's shorthand dethrone select cell C2, then type (or copy and paste it here) the formula:
= AND(A2=B2, A2≠"")
Select cell C2, copy
Select cells C2 at the end of the C column, paste
the formula say to check to see if the cell in column A is NOT empty, and is equal to the cel in column B
Now in the summary table (single cell table):
A1 = COUNTIF (Data::C, TRUE)
-
The second column must be more or less double first thant.
It's the definition of the form:
< af:panelFormLayout id = "pfl1" lines = '6' labelWidth = "120".
Binding = "#{backingBeanScope.detalleBB.pfl1}" >
two columns of fields is displayed.
The second column has several panelgrouplayout - horizontal with three different areas requiring a more horizontal space than the first column which are fields of inoputtext.
Currently the panelform gives the same horizontal space resulting in the packing in the second two-column and this conditioning is what I want to avoid.
Thank you in advance.
You plan to create another PanelFormLayout with a different width and put the two forms of panel inside a horizontal panel group presentation so that they compare side by side?
-
Hello
I found a nice piece of code in the forum, which extends a JComboBox to display
two columns.
Now I am trying to add my own demands, namely the combo should be editable
and only the first column should appear in the edit field and become the
selected value.
I thought to write an own editor that "catches" the posting process for
manipulate the text that will be displayed. Because the rendering engine uses a
JPanel to display columns, I expect this Panel must be passed in the
setItem method (...) the editor. But it isn't, and I can't even detect
what object is passed.
I wonder if this approach is advisable at all. If comments or ideas
are welcome.import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main extends JFrame { public static final long serialVersionUID= 70L; public Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); final JComboBox<Object> priceList = new JComboBox<>(new Object[] { new Object[] { "Lemon", 0.5 }, new Object[] { "Cherry", 3 }, new Object[] { "Apple", 1 }, }); priceList.setEditable(true); priceList.setEditor(new MyEditor()); priceList.setRenderer(new MyRenderer()); add(priceList, BorderLayout.CENTER); JButton b= new JButton("OK"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(priceList.getSelectedItem()); } }); add(b, BorderLayout.SOUTH); pack(); } public static void main(String... args) throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { new Main().setVisible(true); } }); } class MyEditor extends JTextField implements ComboBoxEditor { public static final long serialVersionUID= 71L; public Component getEditorComponent() { return this; } public Object getItem() { return getText(); } public void setItem(Object obj) { System.out.println("Setting item"); System.out.println(obj); if (obj instanceof JPanel) System.out.println("Panel"); if (obj instanceof JLabel) System.out.println("Label"); if (obj instanceof String) System.out.println("String"); setText("Hello"); } } /** * This class uses panel with two labels to render the list (combobox) cell. */ class MyRenderer extends JPanel implements ListCellRenderer<Object> { public static final long serialVersionUID= 72L; JLabel labels[] = { new JLabel(), new JLabel() }; public MyRenderer() { setLayout(new GridBagLayout()); // Add labels GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.1; add(labels[0],c); add(labels[1]); } public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Object rowData[] = (Object[])value; // Prepare colors Color foreground = isSelected? list.getSelectionForeground(): list.getForeground(); Color background = isSelected? list.getSelectionBackground(): list.getBackground(); // Set panel colors setForeground(foreground); setBackground(background); int col = 0; for(JLabel label : labels) { label.setBackground(background); label.setForeground(foreground); label.setText( String.valueOf(rowData[col++]) ); } return this; } } }
As an alternative, I thought that usiing a JComboBox 'ordinary' with the strings in column 1 as elements and you try to change the popup so that it displays and column 2.
You can render the comboBox and the popup differently. Just check for an index of-1 for the drop-down list box.
Different examples of how you can restore more than one column in a combo box. The example of "text pane" has been changed so that the drop-down list box shows only one column while the popup shows the two columns:
import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.text.*; public class ComboBoxMultiColumn extends JFrame { public ComboBoxMultiColumn() { getContentPane().setLayout( new GridLayout(0, 2) ); Vector items = new Vector(); items.addElement( new Item("123456789", "Car" ) ); items.addElement( new Item("23", "Plane" ) ); items.addElement( new Item("345", "Train" ) ); items.addElement( new Item("4567", "Nuclear Submarine" ) ); // Use a JTextArea as a renderer JComboBox comboBox1 = new JComboBox( items ); comboBox1.setRenderer( new TextAreaRenderer(5) ); getContentPane().add( new JLabel("TextArea Renderer") ); getContentPane().add( comboBox1 ); // Use a JTextPane as a renderer JComboBox comboBox2 = new JComboBox( items ); comboBox2.setRenderer( new TextPaneRenderer(10) ); getContentPane().add( new JLabel("TextPane Renderer") ); getContentPane().add( comboBox2 ); // Use a JPanel as a renderer JComboBox comboBox3 = new JComboBox( items ); comboBox3.setRenderer( new PanelRenderer(50) ); getContentPane().add( new JLabel("Panel Renderer") ); getContentPane().add( comboBox3 ); // Using HTML JComboBox comboBox4 = new JComboBox( items ); comboBox4.setRenderer( new HTMLRenderer() ); getContentPane().add( new JLabel("HTML Renderer") ); getContentPane().add( comboBox4 ); } class Item { private String id; private String description; public Item(String id, String description) { this.id = id; this.description = description; } public String getId() { return id; } public String getDescription() { return description; } public String toString() { return description; } } public static void main(String[] args) { JFrame frame = new ComboBoxMultiColumn(); frame.setDefaultCloseOperation( EXIT_ON_CLOSE ); frame.pack(); frame.setVisible( true ); } /* ** Tabs are easier to use in a JTextArea, but not very flexible */ class TextAreaRenderer extends JTextArea implements ListCellRenderer { public TextAreaRenderer(int tabSize) { setTabSize(tabSize); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Item item = (Item)value; setText(item.getId() + "\t" + item.getDescription()); setBackground(isSelected ? list.getSelectionBackground() : null); setForeground(isSelected ? list.getSelectionForeground() : null); return this; } } /* ** Tabs are harder to use in a JTextPane, but much more flexible */ class TextPaneRenderer extends JTextPane implements ListCellRenderer { public TextPaneRenderer(int tabColumn) { setMargin( new Insets(0, 0, 0, 0) ); FontMetrics fm = getFontMetrics( getFont() ); int width = fm.charWidth( 'w' ) * tabColumn; TabStop[] tabs = new TabStop[1]; tabs[0] = new TabStop( width, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE ); TabSet tabSet = new TabSet(tabs); SimpleAttributeSet attributes = new SimpleAttributeSet(); StyleConstants.setTabSet(attributes, tabSet); getStyledDocument().setParagraphAttributes(0, 0, attributes, false); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Item item = (Item)value; if (index == -1) setText( item.getDescription() ); else setText(item.getId() + "\t" + item.getDescription()); setBackground(isSelected ? list.getSelectionBackground() : null); setForeground(isSelected ? list.getSelectionForeground() : null); return this; } } /* ** Use a panel to hold multiple components */ class PanelRenderer implements ListCellRenderer { private JPanel renderer; private JLabel first; private JLabel second; public PanelRenderer(int firstColumnWidth) { renderer = new JPanel(); renderer.setLayout(new BoxLayout(renderer, BoxLayout.X_AXIS) ); first = new JLabel(" "); Dimension d = first.getPreferredSize(); d.width = firstColumnWidth; first.setMaximumSize(d); second = new JLabel(); renderer.add(first ); renderer.add(second ); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Item item = (Item)value; first.setText( item.getId() ); second.setText( item.getDescription() ); renderer.setBackground(isSelected ? list.getSelectionBackground() : null); renderer.setForeground(isSelected ? list.getSelectionForeground() : null); return renderer; } } /* ** Use HTML to format the text */ class HTMLRenderer extends DefaultListCellRenderer { private static final String START = "
"; public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); Item item = (Item)value; setText(START + item.getId() + MIDDLE + item.getDescription() + END); return this; } } }"; private static final String MIDDLE = " "; private static final String END = " -
Should be changed to two full pages in a single page with two columns
I have a schedule that is formatted to 8 1/2 x 11 size. I want to change this option to display two pages on one page into two columns? How can I do this? Thanks in advance.
It's extremely well beyond what is possible or even imaginable for PDF editing. Redo in Word; You can use export as Word, copy paste and export the images as tools to do this. Then again the PDF file.
-
Unique table with several columns or several tables split?
What is the best.
A table with multiple columns inside or divided into several tables. Why?
How will the performance in the two scenarios?Hello
user13024762 wrote:
I have a table EMP that has column EMP_ID, EMP_NAME MGR_ID, MGR_NAME, SALARY, EXP_IN_MNTHS, EXP_IN_YRS... etc with multiple columnsI have the following tables
EMP-> EMP_ID, EMP_NAMEEach row in the table emp thie represents a separate employee. I guess other columns in the emp table might be birth_date, social_security_number and status (by example, 'Active', 'Leave', 'complete'). Here's what an employee has (at least) one of. If there is a one-to-many relationship between an employee and an attribute, then you probably want another table for this attribute.
BISHOP-> EMP_ID, MGR_ID, MGR_NAME
There is a one-to-many relationship between employees and managers? In other words, an employee may have 2 or more managers? If Yes, then you need another table.
If there is only a one-to-one relationship between employees and managers (in other words, if an employee is never more than 1 Manager) so why don't you just have a mgr_id column in the emp table?
Managers are also used for? (This is often the case, as in scott.emp and hr.employees.) If so, do not store their names in the EME and tables of mgr. Store name (and date of birth and other information) in the table emp only and, if you need a table of Bishop, just the emp_id and mgr_id column.SAL-> EMP_ID, SALARY
There is a one-to-many relationship between the employees and wages? In other words, an employee may have 2 or more treatments? If so, how will you use the values? Is a special treatments in some way, as it will be used more often than others? (In other words, you may have a current and past wages salary, but the last wages are rarely used.)
If you never have more than 1 salary for a given employee, why not just have a sal column in the emp table?EXP-> EMP_ID, EXP_IN_MNTHS, EXP_IN_YRS
There is a one-to-many relationship between the employees and what whether you store in this table?
etc. with more tables
What is the best based on
(1) performance and data recovery
(2) ease of use
(3) maintainabilityA one-to-many relationship requires an additional table. If an employee can have up to 3 managers, don't have mgr1, mgr2 and mgr3 columns in the emp table. Use a separate table, with up to 3 lines for the same employee, instead.
For 1-1 relationships, it is usually best to not have separate tables. -
Hello! I have a problem with my data - I get in a wide range of 1 x 1000, but it's the repeated measures, each taking about 500 data points. I want to break this table for this data string start a new column in my table every 500 points given. I don't know how to do it-please help!
datacompiler100 wrote:
Hey thanks for the sponsor and the first off I must apologize for the State, I am attaching my VI. I put the part of the VI that I am working on (my team has access, so didn't post everything here) and also attached the data file (when just written in a spreadsheet file, not through the attached VI). I want to convert the long row of data and then start a new column every 50, 100, 5 points (user-defined).
Using the data from the file, you can reshape everything simply (as you already!), followed by transposition (since you want columns instead of rows). 2D arrays must always be rectangular, so the last column is filled with zeros if necessary. Is that what you want?
Of course if you try to add a new column in a file, that will not work. You can only add lines in an existing file because of the way the data is organized. To add columns, the entire file must be read, intertwined and all re-written new data in the file.
-
Disable the previous dating date picker in the column in a table
can someone please help.
on the date column in a table, need to disable previous dates.
Current functionality. But when the validation page gets updated and the user is able to select earlier dates.
To restrict the datePicker for new lines changed the URL of the button 'Add Row '.
javascript:myAddRow();
In the page edit, I added this to "Javascript > function and Variable global statement.
function myAddRow()
{ apex.widget.tabular.addRow();
$("td[headers='DETAIL_DATE'] input:last")
.datepicker("option","changeMonth",false)
.datepicker("option","minDate",$v("P2_MASTER_MONTH_MINDATE"))
.datepicker("option","maxDate",$v("P2_MASTER_MONTH_MAXDATE")); };
w/u/p: nani5048/test/test
App 92603 5 page
Thank you
Nani
I created a dynamic action
the loading of the page
$("td [en-têtes = 'STATUS_DATE'] entrée")
. DatePicker ("option", "minDate", $v ("P5_MASTER_MONTH_MINDATE"));
as well as the global javascript function
function myAddRow() {}
apex.widget.tabular.addRow ();
$("td [en-têtes = 'STATUS_DATE'] entrée")
. DatePicker ("option", "minDate", $v ("P5_MASTER_MONTH_MINDATE"));
}
Maybe you are looking for
-
Session restore saving connection token
When I close Firefox and open it again I am is more connected to my account to Google and it is normal (I ask that my login details not recorded). However if I use the option to restore previous session I logged into my Google accounts. Why is the co
-
New tab opens with the Bing search engine
So I'm having exactly the same problem like this: https://support.mozilla.org/en-US/questions/959280 In short, I updated firefox and now the new tabs always open with a bing search engine. The url that keeps opening is: search.conduit.com/?ctid=CT331
-
Re: Error with driver Bluetooth Stack on protected Z830
Error during installation of the Bluetooth stack for Windows 7 (version of 15/05/12): first pilot "Bluetooth USB controller-10" properly installed but the second a "Bluetooth RFBUS" fails. Therefore Bluetooth does not work. PC says that it is not ena
-
VPN - integrated or Tunnelblick?
I use the native OS X (El Capitan) VPN, built-in client and it works. It is L2TP, which is not serious, but Open VPN is better. My question is if Open VPN is enough better to justify moving to Tunnelblick VPN client open source. Thank you.
-
MY C drive is almost full and my system is slow, I am enrolled in Windows XP Professional in my laptop, I am originally from Pakistan, but currently I am in Saudi Arabia and have no CD/Media and keys als. Where can I get the key in the windows file?