all groups > sql server mseq > august 2006 >
You're in the

sql server mseq

group:

Simple SQL statement question



Simple SQL statement question Bkana
8/24/2006 9:43:02 AM
sql server mseq: 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.

Thank you,
Re: Simple SQL statement question Hugo Kornelis
8/24/2006 10:45:42 PM
[quoted text, click to view]

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.

--
AddThis Social Bookmark Button