Solved

Advanced Sql Select statement

Posted on 2007-11-18
3
1,010 Views
Last Modified: 2013-12-07
I have a database of 1.6 million products, all of them pertaining to a certain "category" that wasn't even set forth by me. Is there a specific statement I can do to get all the categories only once? For example, the results to be:
computers
art
electronics
software
NOT:
computers
computers
art
computers
software
software
0
Comment
Question by:jumpstart0321
3 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 20309933
group by category?
0
 
LVL 12

Accepted Solution

by:
RWrigley earned 500 total points
ID: 20309945
Use the "DISTINCT" clause on you select statement?

If you're database server is 2005, you could create an indexed view based on the category, and select form the view; this will not only give you just the distinct categories, but it'll also be much, much faster then scanning the 1.6million row table.
0
 

Author Comment

by:jumpstart0321
ID: 20310017
DISTINCT did it. Thanks :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now