what is a sub query?how will you calculate working days in
a month using sub query?
Answers were Sorted based on User's Feedback
Answer / ankur akash
A query inside a query is a sub query.
The first query depends for its execution based on the
result provided by the execution of inside query. i.e. subquery.
For ex.
Select last_name, salary, job_id
from employees
where salary >(select last_name, salary
from employees
where last_name = 'Higgins');
Here
Select last_name, salary, job_id
from employees
where salary >
talks about the first query depending for its result based
on the execution of the inner query i.e. sub query
(select last_name, salary
from employees
where last_name = 'Higgins');
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / thiyagarajan
A subquery is a select statement within another select
statement.subquery is executed only once and the parent or
outer query will always depends on the value returned by it.
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / mohana sundaram
to extract data from single table or multiple tables
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / p.rajasekar
ex
1)Method
Table tab1 data like Followings
Month date1 Working
Jan 1 0
Jan 1 1
Jan 1 1
Jan 1 0
.
.
.
Then the query should be
select Month,count(Working) from monthname m where working=1
group by Month,working
You will get answer 2;
2 Method
If we store the working days in same column
eg like(1=>Denotes Working,0=>denotes off)
Month Day1
Jan 101010101111
select Month,length(trim(replace(b.Day1,'0','')))
NoofWorkDays from workdays b
Please test it.Let me know the feed back
Is This Answer Correct ? | 1 Yes | 2 No |
how to rename an existing column in a table? : Sql dba
What is pl sql and why it is used for?
Can you select everything, but 1 or 2 fields, without writer's cramp?
How does postgresql compare to oracle/db2/ms sql server/informix?
What is the difference between database trigger and stored procedure?
in sql table follw columns r their vehicle_no|servicetype|date|location| 1234 |1FS |1-JAN|PUNE| 4561 |2FS |5-JAN|PUNE| 1234 |PS |7-JAN|PUNE| 1234 |PS |15-JAN|MUMB| i want o/p below vehicleno|1fs|1fsdate|1fslocation|1ps|1PSDATE|1PSLOC|2PS|2PS DATE|2PSLOCA e.g 1234|1FS|1JAN|PUNE|1PS|7JAN|PUNE|2PS|15JAN|MUMBAI PLS help me out to execute using sql query
How to process query result in pl/sql?
how to do backup entire database? : Transact sql
What is serial sql?
What is rtm in testing?
a table has 2 classifications 1)liabilities 2)earnings this liabitity has 2 elements with 2 input values and the earnings have 2 elements with 2 input values i wrote a query so that my input is liability savings amount1 amount2 xxxx null xxxxxx 0 xxx1 null xxxxx1 0 null yyyy 0 yyyy null yyy1 0 yyy1 my problem is --when i developed a report(d2k) with this data my o/p is liabilities,amount1,savings,amount2 xxxx xxxxxx xxx1 xxxxx1 yyyy yyyy yyy1 yyy1 how could i move this savings,savings values 2 palces up. can any body provide me witha better solution
What is nvarchar max in sql?