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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Enlist the data types that can be used in pl/sql?

570


Explain table and field in sql?

581


Can one improve the performance of sql*loader? : aql loader

585


Is join an inner join?

531


Can we use view in stored procedure?

506






Why indexing is needed?

516


What does t sql mean?

532


how to increment dates by 1 in mysql? : Sql dba

539


What is foreign key sql?

550


How do you modify a table in sql?

559


Why do we need databases?

565


table structure: ---------------- col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10 01-mar-2012 11:12:46 01-mar-2012 11:11:23 Write a query to display the result as shown below: col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10

3338


explain the difference between myisam static and myisam dynamic. : Sql dba

513


What is sql procedures and functions?

531


what is a trigger in mysql? Define different types of trigger. : Sql dba

548