Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

db2 query

I have one table with the following details.

SNO SNAME DOJ
------ -------------------- ----------
10 KRISH 2007-03-19
20 REDDY 2007-05-19
30 RRRRR 2007-05-19
40 BBBBB 2008-05-19
50 CCCCC 2009-05-19
60 JJJJJ 2009-05-19
70 JJJJJ 2004-05-19
i want the output in the following format:( no of students
joined in each year(no nedd to consider about month and
date)

year count
--------- ----------
2004 1
2007 3
2008 1
2009 2

Answer Posted / amita sharma

Hi,

You can write the query as below:

select year(doj) as year, count(*) as count from emp_join
group by year(doj);


Let: table name is: emp_join

For furthur clarifications or queries please ask.

Thanks;
Amita Sharma.

Output:

year count

2004 1
2007 3
2008 1
2009 2

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does db2 stand for?

961


Why do we need reorg in db2?

924


What are concurrency issues?

1032


How do I copy a table in db2?

953


What is runstats and reorg in db2?

1241


What are the prerogatives?

1015


List down the data types in the db2 database.

1043


What is buffer pool in the db2 database?

1047


Which component is responsible for processing sql statements and selecting access paths?

1074


What is the difference between cursor stability and repeatable read isolation levels?

1116


What is the physical storage length of the data types date, time, and timestamp?

1042


What is dbrm? What it contains? When it will be created?

994


How to connect to db2 database from windows command line?

1003


When a COBOL-DB2 program in PRODUCTION is updating main tables and gone for long run, what have to do?

3525


List out the data types available.

1084