Solved

Advanced Sql Select statement

Posted on 2007-11-18
3
1,011 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to take different types of Oracle backups using RMAN.
Viewers will learn how the fundamental information of how to create a table.

932 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

10 Experts available now in Live!

Get 1:1 Help Now