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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Select and merge group by

Author  Topic 

jpc82
Starting Member

8 Posts

Posted - 2006-03-10 : 13:15:35
I have no idea if this is even possible, but I hope it is.

I have a view that looks like this.

ID......value
1.......A
1.......B
1.......C
2.......D
3.......E
4.......F
5.......G
5.......H
5.......I

What I want is my query to return this
ID.....Values
1......A, B, C
2......D
3......E
4......F
5......G, H, I

Is there anyway to create a view that does this in MS SQL?

nathans
Aged Yak Warrior

938 Posts

Posted - 2006-03-10 : 13:54:21
http://www.sqlteam.com/item.asp?ItemID=11021

Post here again if you run into problems.



Nathan Skerl
Go to Top of Page

jpc82
Starting Member

8 Posts

Posted - 2006-03-10 : 15:50:45
Thanks for the link. That is exactly what I want to have happen.

Before I start spending too much time trying to get this to work for my tables I had one question.

Is it possible to do this without a second table?

I just want to be able to create a single view which uses my existing tables to do this in realtime, and not have to run a stored procedure to update the second table and use that one.
Go to Top of Page

nathans
Aged Yak Warrior

938 Posts

Posted - 2006-03-10 : 16:48:50
Post your tables and some sample data / desired results and well give it a shot.

You can also refer this: http://www.sqlteam.com/item.asp?ItemID=2368

You will need to either use a temp table, add a column to your existing table and perform an update, etc.

Nathan Skerl
Go to Top of Page

jpc82
Starting Member

8 Posts

Posted - 2006-03-13 : 08:33:35
The 2 views that I will be using are structured like this

V_Imp - this is basically the listing of all needed projects
ProjectID...Start Date...End Date
1...........1/1/2001.....1/2/2001
2...........1/3/2001.....1/4/2001
3...........1/5/2001.....1/7/2001
4...........1/9/2001.....1/9/2001
5...........1/10/2001.....1/10/2001

V_Project_Application
ProjectID....Application
1............App1
1............App2
2............App3
4............App1
4............App1
4............App6
5............App9
5............App100

My query needes to return the result

ProjectID...Start Date...End Date...Applications(CVS listing)


Any help would be appreciated
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-13 : 08:39:00
Refer this
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -