Query combining two tables
I have the following two tables:
Asset_Issued
Asset_Type_ID | Assigned to |
1 | RAM |
2 | RAM |
3 | RAM |
4 | RAM |
5 | RAM |
1 | Riadh |
3 | Riadh |
5 | Riadh |
1 | Rajesh |
3 | Rajesh |
2 | Rajesh |
Asset_Type
Asset_Type_ID | Asset_Name |
1 | Laptop |
2 | Desktop |
3 | Mouse |
4 | Keyboard |
5 | Monitor |
Can someone help me with the query that will give the following result.
Asset_Issued_Count
Asset_Name | County |
Laptop | 3 |
Desktop | 2 |
Mouse | 3 |
Keyboard | 1 |
Monitor | 1 |
Really? It's really basic things.
Select at.asset_name, count (*)
of asset_type to
Join asset_issued HERE on (ai.asset_type_id = at.asset_type_id)
At.asset_name group;
Tags: Database
Similar Questions
-
Combine two tables 1 d in a 2D array
Hi all
Maybe I forget what is obvious, but I can't find a solution to combine two tables 1 d in a 2D array AND (it is the impossible part for me) using the tables columns instead of lines.
Example:
Table 1:1, 2, 3, 4
Table 2:5, 6, 7, 8
Result: 1, 5
2, 6
3, 7
4, 8
The 'build array' function seems to add all tables as lines... I guess I could transpose the table, but I want it runs in a Subvi in constructions of different loop and I feel a little uncomfortable with it - I guess one would be left with a completely mixed table. I was maybe blind just to find the right function?
Cheers, Jessi
Hi Jessi,
by default, LV is combining tables in rows. So when you need columns you must transpose the sets or use a different indexing scheme...
-
Hello
I have a while loop that runs trough each case in a box structure. Each of these cases produced a 1 d table. How can I combine these tables in a 2d array. An attempt with two cases is attempted in the attached diagram.
The problem is it seems to fill the first column with zeroes when you add the second row in table
Hi Jagwa,
first: use a registry to offset instead of tunnels. In this way, the result of the first iteration is not lost in the 2nd
"It seems to fill the first column with zeroes" - no, just the table of origin once again, but now by replacing the second row!
2nd:
When your loop runs twice, all the time why not use a FOR loop instead? No need to check for "I".<>
-
recursive query with two tables
Hello
Im having problems of recursive query construction and add to select the list to see the result in hierarchical mode, so I want to your advice.
I have two tables:
And I want to see the result like this:TABLE: t1 c_id parent_id c_level 1 - 1 2 1 2 3 1 2 4 - 1 5 4 2 6 5 3 TABLE: t2 c_id c_name 1 name1 2 name2 3 name3 4 name4 5 name5 6 name6
-Name1
-name2
-Name3
-Name4
-Name5
-name6
Could you please help me with this?
Or maybe can you provide good links where I can find solution how to SELECT LIST looks like the hierarchical tree?Here is my test scenario:
CREATE TABLE t1( c_id NUMBER, parent_id NUMBER, c_level NUMBER); CREATE TABLE t2( c_id NUMBER, c_name VARCHAR2(10)); INSERT INTO t1 VALUEs(1,NULL,1); INSERT INTO t1 VALUEs(2,1, 2); INSERT INTO t1 VALUEs(3,1, 2); INSERT INTO t1 VALUEs(4,NULL,1); INSERT INTO t1 VALUEs(5,4, 2); INSERT INTO t1 VALUEs(6,5, 3); INSERT INTO t2 VALUEs(1,'name1'); INSERT INTO t2 VALUEs(2,'name2'); INSERT INTO t2 VALUEs(3,'name3'); INSERT INTO t2 VALUEs(4,'name4'); INSERT INTO t2 VALUEs(5,'name5'); INSERT INTO t2 VALUEs(6,'name6'); SELECT LPAD('-',2 * a.c_level,'-') || b.c_name the_tree FROM t1 a, t2 b WHERE b.c_id = a.c_id CONNECT BY a.parent_id = PRIOR a.c_id START WITH a.parent_id IS NULL;
and the result:
THE_TREE ---------- --name1 ----name2 ----name3 --name4 ----name5 ------name6
I took the example you gave then perhaps your largest data set has the flaw?
Published by: SunDogCa on August 13, 2010 14:19
-
How to combine two tables: table of origin and its values of interpolation table
We get a new array of values after using the interpolation on a table function in labview, but how to combine the array of values and this original interpolated set of values in a single table?
-
Hi all
Following the script nicely:CREATE TABLE ACCOUNT_LOOCKUP ( SERIAL_ID NUMBER, ACCOUNT_ID NUMBER, ACCOUNT_RATE NUMBER, ACCOUNT_MAX NUMBER ) ALTER TABLE ACCOUNT_LOOCKUP ADD ( CONSTRAINT PK_ACCOUNT_LOOCKUP PRIMARY KEY (SERIAL_ID, ACCOUNT_ID)); Insert into ACCOUNT_LOOCKUP (SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX) Values (1, 1, 10, 200); Insert into ACCOUNT_LOOCKUP (SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX) Values (2, 1, 12, 150); Insert into ACCOUNT_LOOCKUP (SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX) Values (3, 1, 8, 400); Insert into ACCOUNT_LOOCKUP (SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX) Values (1, 2, 7, 100); Insert into ACCOUNT_LOOCKUP (SERIAL_ID, ACCOUNT_ID, ACCOUNT_RATE, ACCOUNT_MAX) Values (2, 2, 5, 200); COMMIT; SELECT * FROM ACCOUNT_LOOCKUP SERIAL_ID ACCOUNT_ID ACCOUNT_RATE ACCOUNT_MAX ---------- ---------- ------------ ----------- 1 1 10 200 2 1 12 150 3 1 8 400 1 2 7 100 2 2 5 200 CREATE TABLE ACCOUNT_AMOUNT( ACCOUNT_ID NUMBER(10), ACCOUNT_AMNT NUMBER(10)) Insert into ACCOUNT_AMOUNT (ACCOUNT_ID, ACCOUNT_AMNT) Values (1, 9); Insert into ACCOUNT_AMOUNT (ACCOUNT_ID, ACCOUNT_AMNT) Values (1, 35); COMMIT; SELECT * FROM ACCOUNT_AMOUNT ACCOUNT_ID ACCOUNT_AMNT ---------- --------------- 1 9 1 35
I want by select query calculte ACCOUNT_TOTAL every ACCOUNT_ID exists in table ACCOUNT_AMOUNT as below , 1. every ACCOUNT_ID have SERIAL_ID and ACCOUNT_RATE and ACCOUNT_MAX in table ACCOUNT_LOOCKUP, 2. to calculte ACCOUNT_TOTAL every ACCOUNT_ID : - order ascending SERIAL_ID exists in table ACCOUNT_LOOCKUP to every ACCOUNT_ID exists in table ACCOUNT_AMOUNT , - make sum ACCOUNT_AMNT every ACCOUNT_ID in table ACCOUNT_AMOUNT, - then, copmare result (sum ACCOUNT_AMNT) with first record after ascending SERIAL_ID, - product (sum ACCOUNT_AMNT) * ACCOUNT_RATE result as ACCOUNT_TOTAL,(in ex: sum ACCOUNT_AMNT = 44 ) , - if ACCOUNT_TOTAL > ACCOUNT_MAX then * ACCOUNT_TOTAL = ACCOUNT_MAX for first record(in ex SERIAL_ID = 1 ) , * Goto the second record by ascending (in ex SERIAL_ID = 2 ) , make ( ACCOUNT_TOTAL / ACCOUNT_RATE ) for first record , ( 200 / 10 ) result 20 >> * calculate Remainder ACCOUNT_AMNT = the sum ACCOUNT_AMNT 44 - 20 = 24 *Goto the second record by ascending (in ex SERIAL_ID = 2 ) , Remainder ACCOUNT_AMNT 24 * (12) ACCOUNT_RATE for second record = 288 as ACCOUNT_TOTAL -if ACCOUNT_TOTAL > ACCOUNT_MAX then * ACCOUNT_TOTAL = ACCOUNT_MAX for second record(in ex SERIAL_ID = 2 ) , * Goto the third record by ascending (in ex SERIAL_ID = 3 ) , make ( ACCOUNT_TOTAL / ACCOUNT_RATE ) for second record , ( 150 / 12 ) result 12.5 * calculate Remainder ACCOUNT_AMNT = the sum ACCOUNT_AMNT 24 - 12.5 = 11.5 Remainder ACCOUNT_AMNT 9.5 * (12) ACCOUNT_RATE for third record = 92 result as ACCOUNT_TOTAL if result <= ACCOUNT_MAX then ACCOUNT_TOTAL = 92
except result ------------ SERIAL_ID ACCOUNT_ID ACCOUNT_RATE ACCOUNT_MAX ACCOUNT_TOTAL ** explain ** ---------- ---------- ------------ ----------- ------------- ***** sum ACCOUNT_AMNT = 44 for ACCOUNT_ID = 1from table ACCOUNT_AMOUNT ****** 1 1 10 200 200 >> (44 * 10 ) = 440 >> 200 /10 rate = 20 >> 44 - 20 = 24 Remainder ACCOUNT_AMNT 2 1 12 150 150 >> (22 * 12 ) = 288 >> 150 /12 rate = 12.5 >> 24 - 12.5 = 11.5 Remainder ACCOUNT_AMNT 3 1 8 400 92 >> (11.5 * 8) = 92 And so on ....
Help me pleaseanother insert Insert into ACCOUNT_AMOUNT (ACCOUNT_ID, ACCOUNT_AMNT) Values (2, 10); SELECT * FROM ACCOUNT_AMOUNT ACCOUNT_ID ACCOUNT_AMNT ---------- --------------- 1 9 1 35 2 10 except result ------------ SERIAL_ID ACCOUNT_ID ACCOUNT_RATE ACCOUNT_MAX ACCOUNT_TOTAL ** explain ** ---------- ---------- ------------ ----------- ------------- ***** sum ACCOUNT_AMNT = 10 for ACCOUNT_ID = 2 from table ACCOUNT_AMOUNT ****** 1 1 10 200 200 2 1 12 150 150 3 1 8 400 92 1 2 7 100 70 10 * 7 = 70
Thanks in advanceHello
Please do not post duplicate questions.
calculate the value of the query help
David
-
Combine two tables using Actionscript Flex Applications errors
Hello
I have a set of Actionscript code below that I would run based on a query and have it display what are all of the selections that I posted from the checkbox elements two repeater.
This doesn't seem to work every time when I get to the checkBox_change2 function. I still see some error messages popping up telling me that I have references null to that particular line: var selArr3:Array = selArr2.concat (selArr);
Could someone tell me how I can get checkBox_change2() don't forget the selections, I did in checkBox_change()? I tried to use public var for the [Bindable] above but I still get the same error.
Thanks in advance.
AliceYou are declaring your selArr not always correctly.
The statement [Bindable] private var selArr:Array; is an instance variable. It is defined outside of any function and is visible from almost anything in your object.In your service
private void checkBox_change(evt:Event,x:Array):void {}
selArr:Array = [];selArr is defined as a local variable that is visible only in the function checkBox_change. Because the names are the same that you override the instance variable. (In reality this is not compiling correctly... your first try for var selArr:Array = [] was the valid syntax for the variable substitution)
To remedy this, you just need to change
selArr:Array = [] in selArr = []; -
Want to combine two tables with different numbers of lines 2d
I'm out data in a file in 2d tables, then adding more as it goes, and I run into issues when the size changes.
2D arrays must be of rectangular shape, so those empty space you have it will be filled with the default value of any data type you are using. See attachment for the concatenation of tables:
-
Update a query with two tables
CREATE TABLE T1
(
FIELD1 VARCHAR2 (10),
VALUE1 INTEGER,
FIELD2 VARCHAR2 (10),
INTEGER VALUE2
)
INSERT INTO T1 VALUES('OLD',100,'NEW',1000);
INSERT INTO T1 VALUES('OLD',200,'NEW',2000);
INSERT INTO T1 VALUES('OLD',300,'NEW',3000);
CREATE TABLE T2
(
DOMAIN VARCHAR2 (10),
AN INTEGER VALUE,
NAM VARCHAR2 (10)
)
INSERT INTO T2 VALUES('OLD',100,'ABC');
INSERT INTO T2 VALUES ('OLD', 200', 'ABC');
INSERT INTO T2 VALUES('OLD',600,'ABC');
INSERT INTO T2 VALUES('OLD',300,'XYZ');
There are currently some old values in table T2. But the current requirement is again present corresponding values in table T1 should be taken into account. A condition more is the NAM = 'ABC '.
I'm writing this way. Is to obtain target updated by several rows from the source. Please help sregard thi.
T2 UPDATE
SET A.FIELD = B.FIELD2, A.VALUE = B.VALUE2
T1 INNER JOIN T2 B
ON T2. VALUE = T1. VALUE1
AND T2. NAM = 'ABC '.
Concerning
KVBYou need something more to...
UPDATE T2 A SET (A.FIELD, A.VALUE)=(SELECT B.FIELD2,B.VALUE2 FROM T1 B WHERE A.VALUE=B.VALUE1) WHERE T2.NAM='ABC'
(not tested)
-
query by default two tables for block
Hello
How can I make defaulet query block of two tables?
I know it's default_query in set_block_property, but there is no clause only 'where' and I put clause of two tables. Is a solution?
concerningYou can use a block of Clause From database. This allows you to base a block on a complex query without having to create a view in the database. Here are the steps:
- Manually create a data block
- Create an item in the block for each column returned by the query - make sure that the data type is correct.
- In the block properties, set the following properties:
- Query data Source type = F R O M Clause query
- Data Source Name = your request
- Mode key = U p d a t a b l e
- Query data Source type = F R O M Clause query
- Manually create a data block
Note: If your query uses summary calculations, make sure you alias the result and ensure that matches alias name of the item in the data of block. It should also be noted that the blocks based on a F r o m query Clause are read-only. If you need be able to update the underlying tables, you can use transactional triggers or the block of data based on a procedure.
For a complete list of this process - Discover My Oracle Support Document ID: * 69884.1 - how to use F rom query Clause in forms *.
Hope this helps,
Craig B-)
If someone useful or appropriate, please mark accordingly.
Published by: Silvere on August 10, 2010 12:37
Help in mandatory query - pulling data from two tables and inserting a
Hi allI need your help for the modification of the query to get the desired result.
I have two tables A and b. using source Insert and select the command, I need to extract data from tables A and B, then insert and C.
Data and table structures are available below.
Table (Source Table)
Status of payment $
MUL DC 20
ONLY DC 20
ONLY 40 PA
MUL NY 50
Table B (Source Table)
State of lang units
E DC 10
S DC 10
NY E 5
PA S 5
Based on query, I need the values in table C as mentioned below.
Table C (Table of Destination) (necessary output query must also be as below)
The State value
PA 8
DC 1
My query is
INSERT INTO C(STATE,VALUE)
SELECT A.STATE, SUM ($) /SUM (UNITS)
OF A, B
WHERE PAYMENT = "SINGLE".
AND A.STATE = B.STATE
GROUP OF A.STATE, B.STATE
But the output I get is
PA 8
DC 2
Essentially to DC, I should get 1, i.e., for payment only $ DC is 20 and divided by 20 DC must be 1.
Let me know where I'm missing.
Hello
It will work you need to add units in the group by clause
SELECT a.state, SUM (dollars) / units
FROM a, (SELECT state, SUM (units) units
FROM b
GROUP BY state) sub
WHERE payment = 'SINGLE' AND a.state = sub.state
GROUP BY a.state, units;
Concerning
Insert two tables with a single query (same ID)
HelloI want to insert two tables at the same time (with a single request) provided that both records get inserted with the same identifier. How can I do this?
Table Movies
id
name
Table Category
movie_id
cat_type
(a) insert in the first table, retrieve the id (can be usingmy_sequence.currval
and then insert into another table.question: He brings three queries to the Database, I also suspect that when several people trying to insert there is a problem, I could be wrong.
I have no other idea.
Greatly appreciated!
think you need to do as an anonymous pl/sql block.
Dim cn As New OracleConnection("DataSource = xx'; user id = xx; password = xx;")
Try
'build the anonymous pl/sql
Dim sb as New System.Text.StringBuilder
sb.Append("declare")
sb.Append(" l_N number;")
sb.Append("begin")
sb.Append("insert into movies (id,name) values (my_sequence.nextval, 'film1') returning id into l_N;")
sb.Append( "insert into category values (l_N, 'Category type');")
sb.Append(" END;")
'create commd object
Dim cmd as New OracleCommand(sb.ToString,cn)
cmd.Connection.Open()
cmd.ExecuteNonQuerry()
cmd.Connection.Close()
cmd.dispose()
Catch ex as Exception
blah blah blah
End try
Published by: pollywog on May 28, 2010 10:48
Published by: pollywog on May 28, 2010 10:49
Hello
I am trying to build a query WITH, but I can't seem to make it work:
WITH P1 AS (SELECT OT_VALUE
OF CSD_OPEN_VERY_HIGH_INCIDENTS VHIGH
WHERE OT_VALUE > = 0
). P2 AS (SELECT OT_VALUE
OF HIGH CSD_OPEN_HIGH_INCIDENTS
WHERE OT_VALUE > = 0
), SELECT VHIGH. OT_VALUE, TOP. OT_VALUE
P1 P2 JOIN INTERNALLY. RATING = P2. RANKING
The two tables have the same column names.
I want to only return a set of results if the two columns (OT_VALUE) contain in reality 1.
Select this check box. This is a job for all four images. This will return the line to the following combinations. 0.0 and 0.1 and 1.0 and 1.1. Importance is 1.2. Let me know if you face any problem
SELECT CASE WHEN ((VH_OT_VAL = 0 ET H_OT_VAL = 0) OR (VH_OT_VAL = 1 AND H_OT_VAL = 0) OR (VH_OT_VAL = 0 AND H_OT_VAL = 1) or (VH_OT_VAL = 1 AND H_OT_VAL = 1)) 1
ANOTHER ACE OF NULL TERMINATOR OT_VAL
DE)
SELECT H.OT_VALUE H_OT_VAL,
VH. OT_VALUE VH_OT_VAL
OF CSD_OPEN_VERY_HIGH_INCIDENTS VH.
CSD_OPEN_HIGH_INCIDENTS H
WHERE NVL (VH. CLASSIFICATION, 0) = NVL(H.CLASSIFICATION,0)
AND VH. IMPORTANCE IN (1,2)
AND H.IMPORTANCE IN (1,2)
AND NVL (VH. OT_GROUP, 0) = NVL(H.OT_GROUP,0)
AND VH. IMPORTANCE = H.IMPORTANCE
AND VH. TIME_STAMP = H.TIME_STAMP
);
Kindly help me with the request to find the data in two tables
Hello GuruKindly help me to recover the data from two tables-
BASEBALL
LEGAL_ENT_ID (PK)
GAME_ID (FK)
LEGAL_ENT_NM
INACTIVE_DT
DATE OF INS_TS
INS_LOGIN
DATE OF UPD_TS
UPD_LOGIN
FOOTBALL
GAME_ID (PK)
BRKR_NM,
BRKR_ISR_ID
BROKER_SYMBOL
INACTIVE_DT
BRKR_SWIFT_FLG
BRKR_INTERNAL_FLG
BRKR_CATEGORY
UPD_TS
MINORITY_FLG
BROKER_TYP
STATUS
INS_TS
INS_LOGIN
UPD_LOGIN
APP_USER
ACTIVE_FLG
and if I want fecth data from these two tables according to the following condition then it is fine with the suite of applications.
1 select distinct values only table of BASEBALL by using the following query.
SELECT DISTINCT B.GAME_ID as 'CLEARING GAME ID', B.BRKR_NM "NAME of THE GAME of COMPENSATION" OF BASEBALL A, FOOTBALL B WHERE A.BROKER_RELATION_CD IN ('FUTBRKR1', 'FUTBRKR2') AND A.GAME_ID = B.GAME_ID
2 Select all the table BRKR_NM OF FOOTBALL as well by using the query - next
SELECT GAME_ID "RUNNING GAME ID", 'NAME OF THE GAME OF EXECUTION' BRKR_NM SOCCER
Now, my query is that--
I want a query that gives me a combination of above mentioned queries... and if I tried to use Union or Union All, then she is not giving me the result as expected.
I like the result to look like who has a few conditions such as -
1 - the records in the table Football are high vs Baseball table because there is no condition to filter the records of the Football.
2 - football is a superset of records and Baseball is a subset.
3 - COMPENSATION NOM_JEU and RUNNING NOM_JEU may return the same values as well.
I want the result to be in the following form-
EXECUTION ID GAME | NAME OF THE GAME TO RUN. COMPENSATION ID GAME | DELETE THE NAME OF THE GAME.
2123 test1 2345 test5
2456 test10 2456 test10
Thanks in advance. Kindly help me.
Published by: user555994 on January 4, 2011 23:48
In the output you want.
All the values of baseball;
Values of football that are matched;
But on what condition you want to match?
How to join two tables of different schemas of Oracle by using a subquery
I'm trying to join two different schemas of Oracle tables using a subquery. I can extract data from each of the tables without problem. However, when I combine select statements it by using a subquery I get Oracle error *'ORA-00936: lack of expression ' *. Given that each SELECT statement runs on its own without error I don't understand what's missing. I'm trying to get the result set is matching the LINE_ID of PDTABLE_12_1 in the schema with the table PDTABLE_201 MAT_DESCRIPTION DD_12809 in the RA_12809 schema.The query is as follows:
SQL = "SELECT [DD_12809]. [PDTABLE_12_1]. LINE_ID OF [DD_12809]. [PDTABLE_12_1] JOIN "_".
+ "(SELECT [RA_12809]. [PDTABLE_201]. MAT_DESCRIPTION "_".
"FROM [RA_12809]. [PDTABLE_201]) AS FAB "_".
+ 'ON [DD_12809]. [PDTABLE_12_1]. PIPING_MATER_CLASS = FAB. PIPING_MATER_CLASS ".
The format of the request is copied from a manual of programming SQL.
I also tried running the query uses a right JOIN on the two tables, but got the same results. Any ideas would be useful. Thank you!
Published by: user11338343 on October 19, 2009 06:55
The format for the join of two tables in Oracle feels like any other database:
SELECT a.col1, a.col2, ..., b.col1, b.col2, ...
FROM schema1.table1 a,
JOIN schema2.table2 b ON a.col = b.col and ...
WHERE a.other_col = 'FRED'
AND ....;
Do not place bracketed identifiers in Oracle. The account that connects to the database must have select privileges on the two tables.
Maybe you are looking for
-
Satellite P200D - black screen and does not just by running
Hello everyone, I have a Toshiba Satellite P200D - 107 PSPBLE with configuration set-aside: Processor: Turion x 2 TL - 52 64-bit clocked at 1.6 GhzDisplay: 17.3 inchGraphics card: Ati radeon x 1200RAM: 2 x 512 MB ram (1 GB total) which I upgraded to
-
Pavilion 23-g013w All In One: RAM - what to buy?
I'm looking to upgrade my 4 GB to 8 GB RAM. But I do not know what look for when I buy. In addition, I did not jump the lid of the computer again. I really want to do it until I have the game to install. So, I don't know if there are two cards of
-
I have a laptop HP-G71-343US. user profile problem.
At the signing, I get the following message - "user profile service has no connection" "profile user cannot be loaded" I immediately stopped. I ran all kinds of diagnostics and nothing seems to be a problem. I had the same problem a few weeks only
-
HP ENVY spectrum XT Ultrabook PC product name operating syatem-windows 7 64 bit. I was faced with a problem regarding the blue screen. Since the last 2 or 3 days, my laptop displays a blue screen, then restarts, so I thought about system recovery opt
-
Can not find information about CSCtf98962 in Bug Toolkit
Hi all We found the CSCtf98962 in the Release Notes for Cisco Unified CCX and Cisco Unified IP IVR 8.0 (2) SU1 in the section warnings resolved. However we have found no information on Bug Toolkit. It shows below when we tried to find CSCtf98962: Dea