Questions tagged [inner-query]

79 questions
0
votes
2 answers

How to write average innerQuery

From the Image I have same course id and multiple videos for i want to show the overall watched percentage as the average of them how can I do that I want something like this: (SELECT SUM(watched_percentage) FROM tbl_student_learning_path where…
Mr world wide
  • 4,696
  • 7
  • 43
  • 97
0
votes
3 answers

Execution Plan of Inner Query different when run as part of a larger query

I faced a puzzling situation. A query had a good execution plan. But when that query was used as an inner query inside a larger query, that plan changed. I am trying to understand why it might be so. This was on Oracle 11g. My query was: SELECT *…
0
votes
1 answer

SQL DB2 how to apply date variable to inner queries?

I have date variable that I have applied to the outer query, but I am receiving an error message: v_Date is not valid in the context where it is used - when trying to use it on the inner queries. Can you help me replace the two 3/31/2016 dates in…
steveW
  • 27
  • 1
  • 8
0
votes
2 answers

inner query issue

I have a doubt regarding an inner query Schema: DEPARTMENT (deptnum, descrip, instname, deptname, state, postcode) ACADEMIC (acnum, deptnum*, famname, givename, initials, title) PAPER (panum, title) AUTHOR (panum, acnum**) FIELD (fieldnum, id,…
0
votes
0 answers

Oracle - Inline Query gives missing right parenthesis error for my code

I am getting missing right parenthesis error on executing the below inline query in oracle: " select * from ( "+ " SELECT P.SZ_PARAM_CODE id, P.SZ_PARAM_DESC cap "+ " FROM prm_vew_parameter P, PRM_PARAMETER_AVAIBILITY A,…
Vivek Jadhav
  • 113
  • 1
  • 1
  • 9
0
votes
1 answer

How to use comma separated values from listagg in inner query?

Consider the query select listagg(''''||Name||'''', ',') within group (order by Name) from STUDENTS; This gives me output as 'Jon','Rob','Bran' How do I use this in inner query consider the following example: with lst as( select…
Rishi Deorukhkar
  • 179
  • 4
  • 15
0
votes
1 answer

SQLServer Delete from table with list coming from another table

I have a DELETE requiring a where with an AND in the WHERE clause to pick the rows. One the of values in the WHERE is actually a bunch of ids. I could accomplish with programming to get the list of user ids and then looping using the list. This…
George
  • 307
  • 1
  • 5
  • 12
0
votes
3 answers

output with condition based sub query in mysql

Below is my query: select c1, c2, c3, c4, c5 from table1 where c1 =0 //Condition 1 AND c2="abc" //Condition 2 AND c3="xxx" //Condition 3 AND c4 = 5 //Condition 4 Here as we know that condition 2 will be applied on result data given by condition 1,…
JP711
  • 93
  • 1
  • 10
0
votes
1 answer

Join queries with same execution plan

I have two queries for the same task ONE: select * from table1 t1 INNER JOIN table2 t2 ON t1.id=t2.id TWO select * from table1 t1 INNER JOIN (select * from table2) t2 ON t1.id=t2.id I checked the execution plan for both the queries.Both…
gkarya42
  • 429
  • 6
  • 22
0
votes
1 answer

How do I pass an inner query value to the outer query to be used in its query in sql?

I need to get a record out of the ASSET table but I only have the parent assetnum to be able to find the entry i need.There are 2 entries with the same assetnum but one has its parent filled with the parent assetnum value i have and one doesn't. I…
mri3
  • 256
  • 3
  • 18
0
votes
1 answer

Inner query not throwing error in postgres

There is a scenario in which we are retrieving some result from inner query and using the result to perform some operation create table test1(key integer,value varchar) insert into test1 values(1,'value 1'); insert into test1 values(2,'value…
SarthAk
  • 1,628
  • 3
  • 19
  • 24
0
votes
2 answers

Parse: Compound Query on Followers times out

I have an activity table which says which users follows who. (fromUser and toUser) I am constructing a leaderboard to see who has the most rating posted, amongst the followers. So I created this query: ParseQuery queryActivityFollowing…
Stephane Maarek
  • 5,202
  • 9
  • 46
  • 87
0
votes
1 answer

SQL inner sub query calculation help needed

I want to calculate balance runtime from totalammount - AmmountReceived = Balance next row .. Totalammont(actually will be previous runtime calculated balance should be here) - AmmountReceived = Balance and so on .... Here is my query which doesnt…
Mike
  • 751
  • 2
  • 10
  • 25
0
votes
0 answers

How to do SQL inner queries through SQLAlchemy

Lets say I have two tables: ticket with columns [id,date, userid] userid is a foreign key that references user.id user with columns [id,name] And I wish to perform the following query through sqlalchemy: select ticket.id, user.name from ( …
Fizi
  • 1,749
  • 4
  • 29
  • 55
0
votes
1 answer

Inner query inside select in laravel query builder?

How can I place inner query inside a select statement in laravel query builder. I want to convert following mysql query in to laravel query builder select i1.client_id,count(*),( select SUM((ii.quantity*ii.rate))as total from invoice_items…
gsk
  • 2,329
  • 8
  • 32
  • 56