SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select multiple attributes
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dzuverink
Starting Member

USA
2 Posts

Posted - 01/31/2013 :  11:22:14  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 01/31/2013 :  12:23:48  Show Profile  Reply with Quote
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

USA
2 Posts

Posted - 01/31/2013 :  12:41:28  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 01/31/2013 :  12:46:33  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000