Displaying Data

Thread Solved
Reply

Join Date: Sep 2008
Posts: 330
Reputation: freshfitz is an unknown quantity at this point 
Solved Threads: 27
freshfitz freshfitz is offline Offline
Posting Whiz

Displaying Data

 
0
  #1
Nov 30th, 2008
I'm trying to display data in cold fusion but when I add my history table I get duplicate listings. I've tried select distinct different joins. How do i join my history table and not get duplicate listings

My store procedure in MS SQL is

  1. USE [Website]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[CheckWebLogin] Script Date: 11/30/2008 09:54:13 ******/
  4. /****** Created BY Ryan Fitzpatrick for Website Customer Interface Script Date: 11/30/2008 09:54:13 ******/
  5. SET ANSI_NULLS OFF
  6. GO
  7. SET QUOTED_IDENTIFIER OFF
  8. GO
  9. ALTER PROCEDURE [dbo].[CheckWebLogin]
  10. @vcemail [varchar] (50) = '_',
  11. @vcPassword [varchar] (50) = '_',
  12. @vcSeason [smallint] = '',
  13. @vcuid [varchar] (50) = '_',
  14. @vccust_no [varchar] (50) = '_'
  15.  
  16. AS
  17. SET NOCOUNT ON
  18.  
  19. SELECT
  20. [dbo].[customer].[cust_no],
  21. [dbo].[customer].[balance],
  22. [dbo].[customer].[firstname],
  23. [dbo].[customer].[lastname],
  24. [dbo].[customer].[email],
  25. [dbo].[customer].[password],
  26. [dbo].[customer].[uid],
  27. [dbo].[customer].[streetno],
  28. [dbo].[customer].[streetnm],
  29. [dbo].[customer].[suffix],
  30. [dbo].[customer].[city],
  31. [dbo].[customer].[state],
  32. [dbo].[customer].[zip],
  33. [dbo].[service].[price],
  34. [dbo].[service].[serv_code],
  35. [dbo].[service].[servstatus],
  36. [dbo].[servcd].[servname],
  37. [dbo].[servhist].[donedate],
  38. [dbo].[employee].[name],
  39. [dbo].[customer].[comp_id]
  40.  
  41.  
  42. FROM
  43. [dbo].[customer]
  44. LEFT OUTER JOIN [dbo].[program] ON [dbo].[customer].[cust_no] = [dbo].[program].[cust_no]
  45. LEFT OUTER JOIN [dbo].[service] ON [dbo].[program].[prog_id] = [dbo].[service].[prog_id]
  46. LEFT OUTER JOIN [dbo].[servcd] ON [dbo].[servcd].[serv_code] = [dbo].[service].[serv_code]
  47. LEFT OUTER JOIN [dbo].[servhist] ON [dbo].[service].[service_id] = [dbo].[servhist].[service_id]
  48. LEFT OUTER JOIN [dbo].[doneby] ON [dbo].[service].[service_id] = [dbo].[doneby].[service_id]
  49. LEFT OUTER JOIN [dbo].[employee] ON [dbo].[doneby].[emp_id] = [dbo].[employee].[emp_id]
  50.  
  51.  
  52.  
  53. WHERE
  54. ([dbo].[customer].[cust_no] = @vccust_no)
  55. AND [dbo].[program].[season] = @vcSeason
  56. AND [dbo].[service].[servstatus] <> 'n'
  57.  
  58.  
  59. ORDER BY dbo.service.serv_code
  60.  
  61.  
  62.  
  63. SET NOCOUNT OFF
My output



Round Name Status Done By Price Done Date
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L04 Grub Guard Round Completed Justin McGill 01-Aug-08 $417.60
L05 Maintenance Round Completed Justin McGill 01-Aug-08 $208.80
L07 Revitalizer Round Completed Ahmed Shaw 29-Aug-08 $208.80
L08 Anytime Lime Round Completed Brendon Massey 09-Jul-08 $208.80
L09 Winter Prep Round Completed Steven Randazzo 18-Nov-08 $208.80
T01 Tree & Shrub Early Spring Skip to late in year $226.80
T02 Tree & Shrub Late Spring Skip Round $226.80
T03 Tree & Shrub Early Summer Skip to late in year $226.80
T04 Tree & Shrub Late Summer Skip to late in year $226.80
T05 Tree & Shrub Fall Skip to late in year $226.80
T06 Tree & Shrub Winterizer Scheduled $226.80
X1 Bug Buster Program Round Completed Hugo Hernandez Millan 27-May-08 $119.94
X2 Bug Buster Program Round Completed Brendon Massey 09-Jul-08 $119.94
X3 Bug Buster Program Round Completed Justin McGill 01-Aug-08 $119.94



Your Current Balance is: $0.00

---------------------------------

Now when i add
left outer JOIN [dbo].[history] ON [dbo].[history].[cust_no] = [dbo].[customer].[cust_no]

I get the data listed 10 times:

Round Name Status Done By Price Done Date
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L01 Rejuvenation Round Completed Brian Boyes 11-Mar-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L02 Crabgrass Barrier Round Completed Hugo Hernandez Millan 27-May-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $208.80
L03 Weed Manager Round Completed Brendon Massey 09-Jul-08 $20
Last edited by freshfitz; Nov 30th, 2008 at 12:04 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,158
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 136
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Displaying Data

 
0
  #2
Dec 1st, 2008
you need to add a group by

  1. GROUP BY cust_no,......
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 330
Reputation: freshfitz is an unknown quantity at this point 
Solved Threads: 27
freshfitz freshfitz is offline Offline
Posting Whiz

Re: Displaying Data

 
0
  #3
Dec 1st, 2008
I tried that and I get this

Column 'dbo.customer.balance' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

The only way I can get rid of the message is if i add all my selects to the group by, But I get the same output with multiple listings
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,158
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 136
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Displaying Data

 
0
  #4
Dec 1st, 2008
what about a distinct

  1. SELECT DISTINCT cust_no

its hard to see where the data is coming from here, if you are wanting the balance only from customer.balance
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 330
Reputation: freshfitz is an unknown quantity at this point 
Solved Threads: 27
freshfitz freshfitz is offline Offline
Posting Whiz

Re: Displaying Data

 
0
  #5
Dec 1st, 2008
It's hard to diagnose without seeing the table structures. But basically I have 3 tables customer, service, and program customer has 1 line program has 1 line item and service has 1 line item. History can have 1 - 1000 line items for each customer number so when i inner join the history table it wants to list the customer line item info for each history line item in the history table. This might be a could fusion question maybe in cold fusion I can filter my loop through statement.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 330
Reputation: freshfitz is an unknown quantity at this point 
Solved Threads: 27
freshfitz freshfitz is offline Offline
Posting Whiz

Re: Displaying Data

 
0
  #6
Dec 1st, 2008
I'm going to close this thread, I think it's a problem in the cold fusion code. Thanks for you help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC