Showing posts with label pretty. Show all posts
Showing posts with label pretty. Show all posts

Friday, March 9, 2012

I Need to rise to the next level of SQL Programming, Recommendations?

This really isn't a SQL Server specific question, but more tword SQL in general. I am pretty good at SQL, being able to perform joins on several tables at one time. I am looking for more challenges in SQL though as I want to learn more and to rise to the next level. Can anyone recommend some good resources to me?

It would be challenging to me to learn how to do more complex queries involving three or more tables.

Ralph

This forums is a good place to start. Keep checking for questions being asked here and see if you can help out. This way you benefit from learning while the poster benefits from getting his issue resolved.

|||

Subscribe to SQL Server Magazine and read Itzik Ben-Gan's articles religiously. And get his books: very deep T-SQL information. Also, get the Inside SQL Server series of books; Kalen Delaney is the series editor.

These are the best resources available, hands down.

Let us know what you think of them, if you get any, okay?

Don

Sunday, February 19, 2012

I need help with a Query and Count

I have a pretty simple query:

Select title, avg(score) from votes group by title order by avg(score) Desc

This returns a result like this:

Abbey Road 4.0
The White Album 3.5
Meet the Beatles 3.0

The values in the score field are always 1, 2, 3, 4, or 5

What I really need from my query is 5 more columns (1, 2, 3, 4, and 5) with a count of how many votes each of those columns received. So the result set might be like this.

Abbey Road 4.0 0 0 1 1 1
The White Album 3.5 0 1 0 0 1
Meet the Beatles 3.0 2 2 2 2 2

I have tried to use the count function, but it counts all the values in the field. I can't figure out how to just count the values that match a certain criteria. When I tried to create subqueries, I got an error that said my subqueries where returning a multiple result sets.

Any suggestions would be greatly appreciated,

Chris

I found a solution using sum and case.

Chris