wsproperties
MIS
I have a rather large sql query that pulls from 4 different tables with left outer joins. The table also has a grouping due to a total. here is a snipplet of the view (note I did the coding in SQL Analyzer then copied code into a view)
select name,addr1,addr2,city,jobname,sum(giving)as giving,email
from name_table left outer join address_table
on name_id=addr_id
left outer join jobs_table on jobs_id=name_id
left outer join gifts_table on gift_id=name_id
left outer join email_table on phone_id=name_id
group by name,addr1,addr2,city,jobname,email
The reason I group by each and every table is because I get an aggregate function error when I leave out the remaining tables.
Questions: 1. When I run the view I get a timeout message. Is the sql view bombing because I am grouping by several fields. 2. Would this be solved if there was a primary key. I ask because I heard you cannot establish a primary key in a view. Ideally I would only group by one or two table fields at best.
select name,addr1,addr2,city,jobname,sum(giving)as giving,email
from name_table left outer join address_table
on name_id=addr_id
left outer join jobs_table on jobs_id=name_id
left outer join gifts_table on gift_id=name_id
left outer join email_table on phone_id=name_id
group by name,addr1,addr2,city,jobname,email
The reason I group by each and every table is because I get an aggregate function error when I leave out the remaining tables.
Questions: 1. When I run the view I get a timeout message. Is the sql view bombing because I am grouping by several fields. 2. Would this be solved if there was a primary key. I ask because I heard you cannot establish a primary key in a view. Ideally I would only group by one or two table fields at best.