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



what is a sub query?how will you calculate working days in a month using sub query?..

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

what is a sub query?how will you calculate working days in a month using sub query?..

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

what is a sub query?how will you calculate working days in a month using sub query?..

Answer / mohana sundaram

to extract data from single table or multiple tables

Is This Answer Correct ?    2 Yes 0 No

what is a sub query?how will you calculate working days in a month using sub query?..

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

Post New Answer

More SQL PLSQL Interview Questions

What is the difference between left outer join and left join?

0 Answers  


What is set transaction?

0 Answers  


What is a REF CURSOR? Compare strong and week ref cursor types.

6 Answers  


When the mutating error will comes? and how it will be resolved?

2 Answers  


explain the delete statements in sql

0 Answers  






What are character functions in sql?

0 Answers  


What is rule base and cost base optimizer?

2 Answers   Thermotech,


What is the difference between subquery and correlated query?

0 Answers  


what are the type of locks ? : Sql dba

0 Answers  


What is difference between cursor and trigger?

0 Answers  


When a dml statement is executed, in which cursor attributes, the outcome of the statement is saved?

0 Answers  


how many values can the set function of mysql take? : Sql dba

0 Answers  


Categories