Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 groub by or select distinct with multiple fields

Author  Topic 

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-06-09 : 08:54:49
here is my query I need to select destinct sopnumbe.. thanks for any help
 select a.sopnumbe,       
b.itemnmbr,
b.itemdesc,
a.bachnumb,
a.invodate,
a.cstponbr,
a.duedate,
b.quantity,
b.unitprce,
c.cmmttext, /* txt field */
a.locncode
from dbo.boa_sop_header_vw a left join dbo.boa_sop_lines_vw b on a.sopnumbe = b.sopnumbe left join dbo.boa_sop10202_vw c on c.sopnumbe = b.sopnumbe
and b.soptype = c.soptype
WHERE a.custnmbr = 'BOA0028892'AND cmmttext like '%%PU@%'


raky
Aged Yak Warrior

767 Posts

Posted - 2009-06-09 : 08:56:35
Use Distinct in select statement
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-09 : 08:57:02
[code]
select distinct sopnumbe
from
(
select a.sopnumbe,
b.itemnmbr,
b.itemdesc,
a.bachnumb,
a.invodate,
a.cstponbr,
a.duedate,
b.quantity,
b.unitprce,
c.cmmttext, /* txt field */
a.locncode
from dbo.boa_sop_header_vw a left join dbo.boa_sop_lines_vw b on a.sopnumbe = b.sopnumbe left join dbo.boa_sop10202_vw c on c.sopnumbe = b.sopnumbe
and b.soptype = c.soptype
WHERE a.custnmbr = 'BOA0028892'AND cmmttext like '%%PU@%'
) q
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-09 : 08:58:16
Without
table structure and
sample data and
wanted output in relation to sample data
it is hard to help in this case.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-09 : 09:00:42
Ooh my mates seem to be of another opinion


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -