October 13, 2009 at 6:04 pm
Hi,
I have a need to output one row per customer with multiple columns of data, like a checkbox. Such as:
CustomerName HBO CineMax Starz
Homer Simpson X X
Bart Simpson X X
Lisa Simpson X X
tblCustomer (CustomerID, CustomerName, MovieChannelID)
tblMovieChannel (MovieChannelID, MovieChannelName)
How do I write the SQL for this?
Thanks.
October 13, 2009 at 6:06 pm
You know, the people that help out here are all un-paid volunteers. Providing the DDL scripts (CREATE TABLE, CREATE INDEX, etc.) for the tables affected, and INSERT statements to put some test data into those tables that shows your problem will go a long way in getting people to look at your issue and help you out. Please include code for what you have already tried. Don't forget to include what your expected results should be, based on the sample data provided. As a bonus to you, you will get tested code back. For more details on how to get all of this into your post, please look at the link in my signature.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
October 13, 2009 at 7:02 pm
You can also read up on PIVOT/UNPIVOT. 🙂
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 13, 2009 at 7:16 pm
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply