Skip to main content
Inspiring
April 21, 2009
Question

CF Query Question

  • April 21, 2009
  • 1 reply
  • 1102 views

I wrote a query that basically pulls all stores from the store table. Within the table, a store could have multiple records, For example, store #1 could have 20 records for it. When I use coldfusion to display the results of the query, is there a way to consolidate the records so that each store only occupies 1 line. For example:

store #1 - all records for store #1

Store #2

Store #3

etc.

and NOT

Store #1

Store #1

Store #1

Any help would be much appreciated.

This topic has been closed for replies.

1 reply

ilssac
Inspiring
April 21, 2009

Choice A)

SELECT DISTINCT store

FROM aTable

Choice B)

<cfoutput query="stroreQry" group="store">

...

</cfoutput>

JatrixAuthor
Inspiring
April 21, 2009

That did consolidate them, but lets say that in the records there is a field called inventory.

so if I have records for store #1 like:

Store                Inventory

1                      2

1                      3

1                      1

So when the fields are combined it shows like this:

Store                Inventory

1                      6

2                      1

3                      8

etc...

Any way to do this?

ilssac
Inspiring
April 21, 2009

Jatrix wrote:

Any way to do this?

I hear good things about "Teach Yourself SQL in 10 Minutes" and "Database Design for Mere Mortals".

SELECT

  store,

  sum(inventor)

FROM

  aTable

GROUP BY

  store