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...

write a query to follwoing table

amount year quarter
254556 2003 first
546332 2003 second
129034 2003 third
490223 2003 fourth
165768 2004 first
265443 2004 second
510412 2004 third
435690 2004 fourth

i want the output

year q1_amount q2_amount q3_amount q4_amount
2003 254556 546332 129034 490223
2004 165768 265443 510412 435690

Answer Posted / ankit kansal

The above answer is perfectly fine, however you can achieve the same using case

Select YEAR,SUM(q1_amt)q1_amt,SUM(q2_amt)q2_amt,SUM(q3_amt)
q3_amt,SUM(q4_amt)q4_amt from (
select YEAR,
CASE QUARTER WHEN 'first' THEN amount ELSE 0 END as q1_amt,
CASE QUARTER WHEN 'second' THEN amount ELSE 0 END as q2_amt,
CASE QUARTER WHEN 'third' THEN amount ELSE 0 END as q3_amt,
CASE QUARTER WHEN 'fourth' THEN amount ELSE 0 END as q4_amt
from t_name) temp group by YEAR;

http://deepinopensource.blogspot.in/

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define Pmrep command?

1116


Why can't we connect source qualifier and aggrigator transformation to an expression ? Why they resticted to conncet 2 active trasformations to an passive transformation ?

2249


What is the status code in stored procedure transformation?

1236


What is standalone command task?

1376


What is workflow? What are the components of workflow manager?

1235


The question was on time stamp. what is the difference between HH and HH24 when to use when.

2129


What is meant by query override?

1118


What is the scenario which compels informatica server to reject files?

1124


can any one explain about dataflow in the informatica project for bank domain....thanks is advance

10729


What are the challenges you have faced in your Project (DWH- ETL)? Explain with example?

8265


differences between service based and product based?

2060


What is the difference between SOURCE and TARGET BASED COMMITS? What are the deliverables?in your project?

2190


What is an aggregator transformation?

1148


What does update strategy mean, and what are the different option of it?

1143


What is the format of informatica objects in a repository? What are the databases that informatica can connect to windows?

1250