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.
| Author |
Topic |
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2009-03-18 : 00:25:09
|
| hai, i have custmer table, in which i have custid and person info abt the customer .anothere tble with itemdtlin which i have ,custid and itempurchased..it is like thistblcust custidcustnamecustaddrtblitemdtlcustiditemnoitemnameit will look like this in dtl tablec1 1 laptopc1 2 compc1 3 headphi want to get the custid group by itemname..but i want to get the distinct of custid,how can i do that.help pls |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-18 : 00:38:10
|
| select distinct c.custid, c.custname,i.itemno,i.itemname from tblcust cinner join tblitemdtl i on c.custid = i.custid |
 |
|
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2009-03-18 : 00:46:21
|
quote: Originally posted by bklr select distinct c.custid, c.custname,i.itemno,i.itemname from tblcust cinner join tblitemdtl i on c.custid = i.custid
For the above criteria, i need to get only one row as output..the above query will give all the three rows.That's y im confused |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-18 : 00:50:02
|
| u want the output as c1 1 laptopthen use top 1 |
 |
|
|
|
|
|