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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select multiple attributes

Author  Topic 

Dzuverink
Starting Member

2 Posts

Posted - 2013-01-31 : 11:22:14
I am have a database that contians stores and all of the stores attributes. What I am trying to do is pull store numbers based on a particular attribute. However this particular attribute has 27 different possibilities and I want to run a query that reports back each distinct attribute with the stores numbers listed under each result. I have gotten this to work but it is returning each distinct attribute onto a seperate result tab.
This is the basic SQL that I am starting with (I am working in Navicat SQL Server desktop)

SELECT MailerUId As AE
FROM "Wawa 012113"
WHERE
CAT LIKE 'AE'

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-31 : 12:23:48
post some sample data and explain what you want as outut. Otherwise we cant make out much from your explanation

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Dzuverink
Starting Member

2 Posts

Posted - 2013-01-31 : 12:41:28
I thought I did explain. Copied from initial question as to what I want as it appears you missed it... I want to run a query that reports back each distinct attribute with the stores numbers listed under each result
This is what is being output when I write
SELECT MailerUId As AE
FROM "Wawa 012113"
WHERE
CAT LIKE 'AE'

SELECT MailerUId As BE
FROM "Wawa 012113"
WHERE
CAT LIKE 'BE'

Result 1 (first tab)
AE
6
Result 2 (second tab)
BE
486

This is what I would like to return all on one result tab
AE BE
6 486
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-31 : 12:46:33
see

http://beyondrelational.com/modules/2/blogs/70/posts/10840/dynamic-pivot-in-sql-server-2005.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -