Showing posts with label book. Show all posts
Showing posts with label book. Show all posts

Wednesday, March 28, 2012

Please help in queries

Hi,

I have 5 tables in sql database, naming Book, Category, Subject, UserDownload, User.

In Book table, BookID, BookTitle, CategoryID

In Category table, CategoryID, CategoryName

In Subject table, SubjectID, SubjectName, CategoryID

In UserDownload table, UserID, BookID

In User table, UserID, UserName

I used Book to store information of books. Those books has many categories. In those categories, there is also some subjects.

When user downloads book, I update UserDownload table.

The result I want to get is, Top Ten Download Subject. How can I get? Please help me.

The way I approach this kind of query is to first list the columns I need to return. Then I start thinking about which tables I need to touch to get that data, and then I think about how the data is related. Something like this should work for you:

SELECT
Subject.SubjectID,
Subject.SubjectName,
TopDownloads.BookCount
FROM
Subject
INNER JOIN
Book ON Subject.CategoryID = Book.CategoryID
INNER JOIN
(SELECT TOP 10 BookID, COUNT(*) AS BookCount FROM UserDownload GROUP BY BookID ORDER BY COUNT(*) DESC) AS TopDownloads ON Book.BookID = TopDownloads.BookID

Monday, March 12, 2012

Place or book to test writing T-SQL queries?

Hi,
I am looking for a place where I get to write sql queries and test my sql knowledge.If any one can suggest me site or book where I can test my sql knowledge. I have good exposure of SQL syntax and want to test how I implement it. Also, If Forum moderator can suggest me any book on this to improve myself in T-SQL.

Regards

Download the FREE copy of SQL Server 2005 Express, and use it to test your code on your local computer. Get your copy here.

For books, look at BOTH volumes of Itzak Ben-Gan's Microsoft Press titles.

|||Jump start to test your SQL skills...
http://www.sql-ex.ru/

|||Is there any book that provides sample scenarios for which one can write queries , like questions handbook? I do not have access to web all time, so , was looking for some offline solution. My requirement is getting some real life scenario query making.|||

SQL Server Express is installed locally on your computer, so it can be used whether or not you're connected to the web.

That will give you the environment in which to practice.

As to what to practice, try one of the Celko "puzzle" books or the SQL Server 2005: Applied techniques Step By Step book.

A search on Amazon.com for beginning SQL Server will also give you some possibilities.

Additionally, come to this forum, or any other sql forum where people post questions looking for help, and work on solving their issue(s).

(Even if someone else has provided a solution, disregard that solution while you work on coming up with your own and then check to see what others came up with.)