Re: Simple SQL statement question



On Thu, 24 Aug 2006 09:43:02 -0700, Bkana wrote:

Hello All,

I have a table called invoicedetail with the following fields:
companyname
address
booth number
booth space

In this table a company name could be listed more then once (more then one
row). One row would have the company name and the address, where another row
will have the comapny name and the booth number and booth space data.

I used:
Select companyname, address, booth number, booth space
From invoicedetail

but it pulls the company name twice listing the address on one line and the
booth info on another.

I need the correct syntax that will pull the company name once while also
pulling the address along with it's corresponding booth information. This
table has hundreds of company names.

Hi B,

Try:

SELECT companyname, MAX(address),
MAX("booth number"), MAX("booth space")
FROM invoicedetail
GROUP BY companyname

And find the time ASAP to clear up this mess, put NOT NULL constraints
on the columns and add a PRIMARY KKEY constraint to the companyname
column.

--
Hugo Kornelis, SQL Server MVP
.