sql - Create View with SUM values -


i not sure how approach this, want create view

the columns fullname, studentid, hourspassed, hoursfailed , hourspassed+hoursfailed of students majoring in finance.

but column headings need fullname, studentid, hourspassed, hoursfailed , hoursattempted

so far have:

create view a5t7 select (firstname || ' ' || lastname) "fullname", studentid, hourspassed, hoursfailed,  sum (hourspassed,hoursfailed) "hoursattempted", a5 upper(major1)='fin'or upper(major2)='fin' group ??? order hoursattempted; 

i pretty sure query wrong, somewhere. don't know how approach heading name , sum value. group doesn't seem right.

i need 5 columns sum function add last column

sum() takes 1 argument. so, might try this:

create view a5t7     select (firstname || ' ' || lastname) fullname,            studentid, hourspassed, hoursfailed,             sum(hourspassed + hoursfailed) hoursattempted     a5     group upper(major1) = 'fin' , upper(major2) = 'fin'     order hoursattempted; 

edit:

the above doesn't work because group by clause where clause. think mean:

create view a5t7     select (firstname || ' ' || lastname) fullname,            studentid,              sum(hourspassed + hoursfailed) hoursattempted     a5     upper(major1) = 'fin' , upper(major2) = 'fin'     group firstname, lastname, studentid     order hoursattempted; 

here sql fiddle.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -