Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2003-09-25 : 10:41:59
|
| Hello, I have the following stored proc:SELECT i.ProductId, i.ProductDesc, i.ProductPrice, i.ProductPicture, i.ProductPictureSize, c1.Category, c2.Category, c3.Category, i.ProductColorCodeFROM Cart_Inventory AS iFULL OUTER JOIN Cart_Category1 AS c1 ON c1.Id = i.ProductCategory1FULL OUTER JOIN Cart_Category2 AS c2 ON c2.Id = i.ProductCategory2FULL OUTER JOIN Cart_Category3 AS c3 ON c3.Id = i.ProductCategory3WHERE i.ProductDesc LIKE '%' + @Search + '%'OR ProductId LIKE '%' + @Search + '%'GROUP BY c1.Category, c2.Category, c3.CategoryIt doesn't compile in SQL Server because it states that I have not included all of the fields in the select statement into the GROUP BY clause. But I only want to group on the three fields I have above. Do I have to group on all fields in the select statement?Thanks! |
|
|
JustinBigelow
SQL Gigolo
1157 Posts |
Posted - 2003-09-25 : 10:46:51
|
| Since you are not aggregating any data (i.e. SUM() or COUNT()) why do you need the group by in the first place?Justin"Look at it out there orbiting like it's so cool, we will rule it with an army of replicants!" |
 |
|
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2003-09-25 : 10:49:39
|
| Hmmm...I think wasn't understand group by then...I have some records like this:Category1 category2 category3---------------------------------1 1 32 2 41 1 32 2 4I wanted to ensure that the were displayed in this order...1 1 31 1 32 2 42 2 4Thanks for your reply! |
 |
|
|
JustinBigelow
SQL Gigolo
1157 Posts |
Posted - 2003-09-25 : 10:51:05
|
| Then change your "Group By" to "Order By" and you should be good to go."Look at it out there orbiting like it's so cool, we will rule it with an army of replicants!" |
 |
|
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2003-09-25 : 10:53:01
|
| Uh...right. That make sense. I don't know what I was thinking! THANKS! |
 |
|
|
|
|
|
|
|