Dear All !
Please Correct my SQL String.

        sqlcmd = New SqlCommand("Select top 10 Distinct[Batch No], [Item Name],Decentralization, UOM, Balance from Decentralization order by Serial desc", conn)

When I run this Command I get Following error : incorrect syntax near the keyword 'Distinct'

Recommended Answers

Select Distinct top 10 [Batch No], [Item Name],Decentralization, UOM, Balance from Decentralization order by Serial desc
Distinct should come first before top 10...

Jump to Post

Use group by... Somthing like this
Select distinct ItemName,BatchNo,UOM,Department
from URTABLENAME group by ItemName,BatchNo,UOM,Department.
Include all the column in select and gropu by

Jump to Post

All 5 Replies

Select Distinct top 10 [Batch No], [Item Name],Decentralization, UOM, Balance from Decentralization order by Serial desc
Distinct should come first before top 10...

Dear Sir;
I want Top 1 record for each Item Name, Batch No & Department. What sql code should i give ?
output1

Use group by... Somthing like this
Select distinct ItemName,BatchNo,UOM,Department
from URTABLENAME group by ItemName,BatchNo,UOM,Department.
Include all the column in select and gropu by

Dear Sir !
My Database is : -
output3

**From this I want this Filtured Result :- **

Desigred_Result

Please Write a code for this result.

No one will write code for you... We can just help you..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.