| Author |
Topic |
|
AdamWest
Constraint Violating Yak Guru
360 Posts |
Posted - 2010-10-26 : 13:40:28
|
| HI I Have this table with many transactions records. I need a listing of the customer names. So I want to result set just the first occuranceSELECT TOP 1000 [company] ,[Item_number] ,[Quantity] ,[Price] ,[Customer] ,[Cust_Code] ,[Date_Created] ,[item_name] ,[Category] ,[Department] ,[Budget] ,[PO] ,[home_id] ,[DeliveryDate] FROM [tech2].[dbo].[V_Dashboard_expenses]order by companycompany is the name oi just want first occurance. |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-26 : 13:58:33
|
Which version of SQL Server you are using ?If you are using 2005, then try the below select and let us know whether it meets your requirment or not. Is this you are looking for :Select top 1000 [company],[Item_number],[Quantity],[Price],[Customer],[Cust_Code],[Date_Created],[item_name],[Category],[Department],[Budget],[PO],[home_id],[DeliveryDate]From (SELECT Row_number() over (order by [Date_Created]) as Srno, [company],[Item_number],[Quantity],[Price],[Customer],[Cust_Code],[Date_Created],[item_name],[Category],[Department],[Budget],[PO],[home_id],[DeliveryDate]FROM [tech2].[dbo].[V_Dashboard_expenses]) as SubTabwhere SubTab.Srno = 1order by company |
 |
|
|
AdamWest
Constraint Violating Yak Guru
360 Posts |
Posted - 2010-10-28 : 14:50:28
|
| HI thanks for responsing. We are using sql server 2008 r2.I am getting a syntax error with your codes."Msg 207, Level 16, State 1, Line 18Invalid column name 'company'." |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-29 : 06:41:22
|
quote: Originally posted by AdamWest HI thanks for responsing. We are using sql server 2008 r2.I am getting a syntax error with your codes."Msg 207, Level 16, State 1, Line 18Invalid column name 'company'."
Hi,Its not syntax error. It says that company column is not found in table [tech2].[dbo].[V_Dashboard_expenses].I have taken it from your original post. Check whether company column exists in table or not.If it exists, one possiblity is that the collation is case sensitive. Try to use the same case as found in table structure. |
 |
|
|
|
|
|