d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Anyone Good With Sql > Paying Fg
Add Reply New Topic New Poll
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
Mar 13 2013 02:59pm
need help with writing a couple of sql queries
will pay 100fg per query

assignment is due in 6 hours from this post
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Mar 13 2013 03:14pm
pm me
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 13 2013 03:26pm
post what you need help with :3
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
Mar 13 2013 03:36pm
http://www.bea.gov/iTable/iTable.cfm?ReqID=12&step=1#reqid=12&step=3&isuri=1&1203=15). You created the following tables:

Code
create table prodhierarchy (
  level1 varchar(80),
  level2 varchar(80),
  level3 varchar(80) not null primary key);

create table pceprod (
  prod varchar(80) not null,
  year int not null,
  quarter int not null,
  pce int,
  primary key(prod,year,quarter),
  foreign key(prod) references prodhierarchy
);

create table pcefunc (
  func varchar(80) not null,
  year int not null,
  quarter int not null,
  pce int,
  primary key(func,year,quarter)
);


Q4. Which function, year and quarter saw the biggest increase in PCE from year to year?

The result should have the columns: func, year2, year1, quarter, pce2, pce1

Hint: think of finding for each function and quarter the difference in pce between year x and year x-1. Then do that for every year x.

Q5. What is the annual PCE for each function ?

The result should have the columns: func, year, annualpce

Q6. What is the function, year, and PCE with the most annual PCE ?

The result should have the columns: func, year, annualpce

Q7. Which year has the largest total PCE ? (Use the pcefunc table for this question).

The result should have the columns: year, annualpce

Q8. What is the total PCE for each level two product in the year 2009 ?

The result should have the columns: prodlevel2, totalpce

Q9. What is the annual PCE of "Goods" for each year ?

The result should have the columns: year, annualpce

Q10. What is the difference between the annual PCE for "Goods" and the annual PCE for "Services" (expressed as a percentage over the annual PCE for Services) for the years when the annual PCE for "Services" is greater than the annual PCE for "Goods"? You want the results sorted by most recent years first and the percentage expressed in two decimal points.

The result should have the columns: year, diffpce

This post was edited by bakalolo on Mar 13 2013 03:50pm
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
Mar 13 2013 03:48pm

pcefunc


pceprod


prodhierarchy

if these are the sample data that he gave for the 3 tables
if im not mistaken you can just write the query based off of these

This post was edited by bakalolo on Mar 13 2013 03:49pm
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
Mar 13 2013 06:59pm
finished all but #4 and #10 if anyone could help me with those id pay 150fg per

dont need to look at the link just the schema and the sample data that in the pics

This post was edited by bakalolo on Mar 13 2013 07:00pm
Member
Posts: 2,683
Joined: Jun 27 2009
Gold: 9.00
Mar 14 2013 04:19am
For Q10 just instantiate a temporary column diffpce calculated from the result set. Sorting is then simple.
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
Mar 15 2013 04:10pm
Quote (aCaseofNoob @ Mar 14 2013 12:19am)
For Q10 just instantiate a temporary column diffpce calculated from the result set. Sorting is then simple.


hm never learned how to make temp col... but ill look into it, im mostly having trouble with the part where only pick years when the annual PCE for "Services" is greater than the annual PCE for "Goods"

also he extended the due date till monday morning if anyone still wants to do #4 or 10 ill up it to 200fg per but thats the highest im gonna go

This post was edited by bakalolo on Mar 15 2013 04:17pm
Member
Posts: 12,368
Joined: Sep 2 2005
Gold: 115.02
Mar 15 2013 06:40pm
just wondering, what class is this for
Member
Posts: 20,928
Joined: Mar 18 2009
Gold: 435,910.13
Mar 18 2013 07:28pm
Quote (guiltygearXT @ Mar 15 2013 02:40pm)
just wondering, what class is this for


database class
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll