|
-
Mar 30th, 2004, 04:11 PM
#1
Thread Starter
Fanatic Member
Table Disposition
Hello Guys!
I have a tabe with 2 fields
One Two in that format
One Two
ACSEK AC01
ACSEK AC02
MOPE AC01
MOPE ACME
MOPE AC04
I would like to select the data so that in the display it comes up like this
ACSEK AC01, AC02
MOPE AC01, ACME, AC04
using a select statement
Any ideas?
-
Mar 30th, 2004, 10:18 PM
#2
If you are you using SQL you may be able to write a stored
procedure to do it. Perhaps a cursor for the outter query and
pass the distinct One values to the inner query along with the
count of Twos. The inner query will construct the field Two
containing x number of entries separated by commas. I don't
know if I am explaining this correctly.
I know you could easily do it in VB. Would that be an option?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 31st, 2004, 03:31 AM
#3
You didn't say what you have the db in - Access has a crosstab query type, which might do what you want...
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Mar 31st, 2004, 11:13 AM
#4
I have checked out the crosstab query before I posted. It will not do what Lafor wants. 
Although it does get close.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 31st, 2004, 11:17 AM
#5
Thread Starter
Fanatic Member
....
Thanks Guys...
I am using SQL Server....
-
Mar 31st, 2004, 11:18 AM
#6
I am at work now and we have SQL 2000 so I will try to create an
example for you when I get a chance.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 31st, 2004, 11:19 AM
#7
Thread Starter
Fanatic Member
-
Mar 31st, 2004, 11:21 AM
#8
Did I help you with something before about a year or two ago???
I kind of remember your name. I think it may have been with Outlook?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 31st, 2004, 11:21 AM
#9
Thread Starter
Fanatic Member
Indeed
You have... it was about 3 months ago...
Thanks again
-
Mar 31st, 2004, 11:24 AM
#10
Not a problem. Glad to help.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 31st, 2004, 05:16 PM
#11
Lafor, this will work if executed from query analyzer.
Code:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[LAFOR]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[LAFOR]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [DBO].[LAFOR] AS
--INITIALIZE CURSOR
DECLARE @Kount AS NVARCHAR(10), @One AS NVARCHAR(10), @Two2 AS NVARCHAR(50),
@One2 AS NVARCHAR(50), @Two AS NVARCHAR(10), @Temp AS NVARCHAR(50), @KOUNTTEMP AS INTEGER,
@Temp2 AS NVARCHAR(50)
DECLARE rrCursor SCROLL CURSOR FOR
SELECT
[T1].One,
CAST(COUNT([T1].Two) AS NVARCHAR(10)) AS CountOfTwo
FROM
[Table1] AS T1
GROUP BY
[T1].One
OPEN rrCursor
FETCH FIRST FROM rrCursor
INTO @One, @Kount
--INITIALIZE VARS
SET @Temp = ''
SET @Temp2 = ''
SET @KOUNTTEMP = 1
--START LOOP
PRINT 'BEGIN'
WHILE @@FETCH_STATUS = 0
BEGIN
DECLARE rrCursor2 SCROLL CURSOR FOR
SELECT
[T1].One,
[T1].Two
FROM
[Table1] AS T1
WHERE [T1].One = @One
OPEN rrCursor2
FETCH FIRST FROM rrCursor2
INTO @One2, @Two2
WHILE @KOUNTTEMP < @Kount + 1
BEGIN
SELECT @Temp = @Temp + @Two2 + ', '
SET @KOUNTTEMP = @KOUNTTEMP + 1
SET @Temp2 = @Temp
FETCH NEXT FROM rrCursor2 INTO @One2, @Two2
END
PRINT @One + ', ' + SUBSTRING(@Temp2,1,LEN(@Temp2)-1)
SET @Temp = ''
SET @Temp2 = ''
SET @KOUNTTEMP = 1
FETCH NEXT FROM rrCursor INTO @One, @Kount
CLOSE rrCursor2
DEALLOCATE rrCursor2
END
PRINT 'END'
--DONE
CLOSE rrCursor
DEALLOCATE rrCursor
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
'THEN EXECUTE THE SP
EXECUTE Lafor
'RESULTS
BEGIN
ACSEK, AC01, AC02
MOPE, AC01, ACME, AC04
END
I hope this is what you were looking for.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 6th, 2004, 07:57 AM
#12
Thread Starter
Fanatic Member
Thanks
...Saw you response.... I have been aaccidentally away...
Thanks much...
Thank you
-
Apr 6th, 2004, 09:58 AM
#13
No problem. Glad to help.
You can add to it to make it return a cursor.
Not too much harder, but I haven't done that before.
Later.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|