Sponsored Content
Top Forums Programming Query SQL get two values differents from the same columns Post 302889959 by durden_tyler on Monday 24th of February 2014 02:23:14 PM
Old 02-24-2014
Code:
SQL>
SQL> --
SQL> select * from t1;
 
       INS NAME       VALUE
---------- ---------- ----------
         1 Test       12345
         1 TestV1     12/10/2014
         8 Test       85435
         8 TestV1     11/11/2005
         9 Test       42232
         9 TestV1     19/10/2000
         6 Test       54321
         6 TestV1     11/05/2013
 
8 rows selected.
 
SQL>
SQL> --
SQL> select * from t2;
 
VALUE
----------
12345
54321
 
2 rows selected.
 
SQL>
SQL> -- Method 1
SQL> select x.value, z.value
  2    from t1 x
  3         join t2 y on (y.value = x.value)
  4         join t1 z on (z.ins = x.ins and z.name = 'TestV1')
  5  ;
 
VALUE      VALUE
---------- ----------
12345      12/10/2014
54321      11/05/2013
 
2 rows selected.
 
SQL>
SQL> -- Method 2
SQL> select x.value,
  2         y.testv1_value
  3    from t2 x
  4         join (
  5                   select ins,
  6                          max(case when name = 'Test' then value end) as test_value,
  7                          max(case when name = 'TestV1' then value end) as testv1_value
  8                     from t1
  9                    group by ins
 10              ) y
 11         on (x.value = y.test_value)
 12  ;
 
VALUE      TESTV1_VAL
---------- ----------
12345      12/10/2014
54321      11/05/2013
 
2 rows selected.
 
SQL>
SQL>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

2. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

3. Shell Programming and Scripting

Run SQL thru shell script: how to get a new line when run sql query?

Hi, this's Pom. I'm quite a new one for shell script but I have to do sql on shell script to query some information from database. I found a concern to get a new line...When I run my script, it retrieves all data as wondering but it's shown in one line :( What should I do? I'm not sure that... (2 Replies)
Discussion started by: Kapom
2 Replies

4. Shell Programming and Scripting

Adding columns with values dependent on existing columns

Hello I have a file as below chr1 start ref alt code1 code2 chr1 18884 C CAAAA 2 0 chr1 135419 TATACA T 2 0 chr1 332045 T TTG 0 2 chr1 453838 T TAC 2 0 chr1 567652 T TG 1 0 chr1 602541 ... (2 Replies)
Discussion started by: plumb_r
2 Replies

5. UNIX for Dummies Questions & Answers

Getting values of 2 columns from sql query in UNIX variables

Hi, I have connected to oracle database with sqlplus -s / <<EOF select ename, age from emp where empid=1234; EOF I want to save the values of ename and age in unix shell variables. Any pointers would be welcome.. Thanks in advance!!1 Cheers :):):):) (1 Reply)
Discussion started by: gonchusirsa
1 Replies

6. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

7. Shell Programming and Scripting

Reading values from sql query

I have sql query in shell script. select distinct account_no from adj order by account_no; This query returns account number daily.Sometimes it may return 90 rows sometime it may return 1 row only and someday it may return 0 rows I am storing the output of this query in sql_output.txt. ... (5 Replies)
Discussion started by: rafa_fed2
5 Replies

8. Shell Programming and Scripting

Request: How to Parse dynamic SQL query to pad extra columns to match the fixed number of columns

Hello All, I have a requirement in which i will be given a sql query as input in a file with dynamic number of columns. For example some times i will get 5 columns, some times 8 columns etc up to 20 columns. So my requirement is to generate a output query which will have 20 columns all the... (7 Replies)
Discussion started by: vikas_trl
7 Replies

9. Shell Programming and Scripting

awk - matching on 2 columns for differents lines

Given this file (I separated them in block to make my explanation clearer): 92157768877;Sof_deme_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 92157768877;Sof_trav_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 91231838895;Sof_deme_faible_Email_am;EMAIL;26/01/2015;1 0;0... (1 Reply)
Discussion started by: Andy_K
1 Replies

10. Shell Programming and Scripting

Asign to variable ksh some values of sql query

Hi, I'm trying to asign to ksh varible some values of a sql query. The output query would be: xxxx 1 yyyy 2 I do: values=`$PATH_UTI/query_sh " select think1||'------'||think2 from some_table where think3 = '$1'; ... (2 Replies)
Discussion started by: mierdatuti
2 Replies
TIX(3)							       Tix Built-In Commands							    TIX(3)

NAME
tixGrid - Create and manipulate Tix Grid widgets -background -borderWidth -cursor -font -foreground -height -highlight- Color -highlightThickness -relief -selectBackground -selectForeground -width -xScrollCommand -yScrollCommand WIDGET-SPECIFIC OPTIONS [-editdonecmd editDoneCmd] If non-empty, gives a Tcl command to be executed when the user has edited grid cell. When this command is called, it is passed with two additional parameters: x y, where (x,y) is the location of the cell that has just been edited. [-editnotify- cmd editNotifyCmd] If non-empty, gives a Tcl command to be executed when the user tries to edit a grid cell. When this command is called, it is passed with two additional parameters: x y, where (x,y,) is the location of the cell. This command should return a boolean value: true indicates that the cells is editable and false otherwise. [-formatcmd formatCmd] If non-empty, gives a Tcl command to be executed when the grid cells need to be formatted on the screen. Normally, this command calls the format widget command (see below). When this com- mand is called, it is passed with five additional parameters: type x1 y1 x2 y2. type gives the logical type of the region in the grid. It may be one of the following. x-region: the horizontal margin; y-region: the vertical margin; s-region, the area where the the horizontal and vertical margins are joined; main: all the cells that do not fall into the above three types. x1 y1 x2 y2 gives the extent of the region that needs formatting. [-leftmargin leftMargin] In the number of cells, gives the width of vertical margin. A zero indicates that no vertical should be drawn. [-selectmode selectMode] Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either single, browse, multiple, or extended; the default value is sin- gle. [-selectunit selectUnit] Specifies the selection unit. Valid values are cell, column or row. [-topmargin topMargin] In the number of cells, gives the height of horizontal margin. A zero indicates that no horizontal should be drawn. DESCRIPTION
The tixGrid command creates a new window (given by the pathName argument) and makes it into a tixGrid widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the tixGrid widget such as its cur- sor and relief. A Grid widget displays its contents in a two dimensional grid of cells. Each cell may contain one Tix display item, which may be in text, graphics or other formats. See the tixDisplayStyle manual page for more information about Tix display items. Individual cells, or groups of cells, can be formatted with a wide range of attributes, such as its color, relief and border. WIDGET COMMAND
The tixGrid command creates a new Tcl command whose name is the same as the path name of the tixGrid widget's window. This command may be used to invoke various operations on the widget. It has the following general form: pathName option ?arg arg ...? PathName is the name of the command, which is the same as the tixGrid widget's path name. Option and the args determine the exact behavior of the command. The following commands are possible for tixGrid widgets: pathName anchor option ?args ...? Manipulates the anchor cell of the tixGrid widget. The anchor cell is the end of the selection that is fixed while the user is drag- ging out a selection with the mouse. pathName bdtype TODO place holder pathName cget option Returns the current value of the configuration option given by option. Option may have any of the values accepted by the tixGrid command. pathName configure ?option? ?value option value ...? Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo(n) for information on the format of this list.) If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given wid- get option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the tixGrid command. pathName delete dim from ?to? Dim may be row or column. If to is not given, deletes a single row (or column) at the position from. If to is given, deletes the range of rows (or columns) from position from through to. pathName edit apply If any cell is being edited, de-highlight the cell and applies the changes. pathName edit set x y Highlights the cell at (x,y) for editing, if the -editnotify command returns true for this cell. pathName entrycget x y option Returns the current value of the configuration option given by option of the cell at (x,y). Option may have any of the values accepted by the set widget command. pathName entryconfigure x y ?option? ?value option value ...? Query or modify the configuration options of the cell at (x,y). If no option is specified, returns a list describing all of the available options for the cell (see Tk_ConfigureInfo(n) for information on the format of this list.) If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified.) If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the set widget command. pathName format TODO place holder pathName index TODO place holder pathName move dim from to offset Dim may be row or column. Moves the the range of rows (or columns) from position from through to by the distance indicated by off- set. For example, move row 2 4 1 moves the rows 2,3,4 to rows 3,4,5. pathName set x y ?-itemtype type? ?option value...? Creates a new display item at the cell at (x,y). The optional -itemtype parameter gives the type of the display item. An additional list of option-value pairs specify options of the display item. If a display item already exists at this cell, the old item will be deleted automatically. pathName size dim index ?option value ...? Queries or sets the size of the row or column given by dim and index. Dim may be row or column. Index may be any non-negative inte- ger that gives the position of a given row (or column). Index can also be the string default; in this case, this command queries or sets the default size of all rows (or columns). When no option-value pair is given, this command returns a list containing the current size setting of the given row (or column). When option-value pairs are given, the corresponding options of the size setting of the given row are changed. Option may be one of the foll- wing: -pad0 pixels Specifies the paddings to the left or a column or the top of a row. -pad1 pixels Specifies the paddings to the right or a column or the bottom of a row. -size val Specifies the width of a column or the height of a row. Val may be: auto -- the width of the column is set the the widest cell in the column; a valid Tk screen distance unit (see Tk_GetPixels(n)); or a real number following by the word chars (e.g. 3.4chars) that sets the width of the column to the given number of characters. pathName unset x y Clears the cell at (x,y) by removing its display item. pathName xview TODO place holder pathName yview TODO place holder KEYWORDS
grid, spread sheet, table Tix 4.1 TIX(3)
All times are GMT -4. The time now is 05:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy