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 |
|
eugz
Posting Yak Master
210 Posts |
Posted - 2010-11-17 : 10:44:01
|
| Hi All.I would like to calculate field Result. What wrong in my select?SELECT DateT, Sum(case when Result = 'NEG' then 1 else 0 endFROM Table1Thanks. |
|
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-11-17 : 10:58:11
|
| Missing ) after end. |
 |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2010-11-17 : 11:08:03
|
| Thanks for replay.That is just wrong type in the post. When I run select I got error message: "Incorrect syntax near 'NEG'."Thanks. |
 |
|
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-11-17 : 11:12:11
|
| Can you give the table structure and sample data? |
 |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2010-11-17 : 11:32:51
|
| TABLE [dbo].[Table1]( [Test_id] [bigint] IDENTITY(1,1) NOT NULL, [DateT] [datetime] NULL, [Result] [varchar](50) NULL CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED ([Test_id] ASCData:Test_id DateT Result11 5/20/2003 0:00 NEG12 5/30/2003 0:00 ASS13 5/21/2003 0:00 NEG15 6/4/2003 0:00 NEG16 5/1/2003 0:00 HGL17 6/19/2003 0:00 NEG18 5/20/2003 0:00 NEG19 6/3/2003 0:00 NEG20 5/30/2003 0:00 ASS |
 |
|
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-11-17 : 11:53:14
|
| What should the expected outcome be? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2010-11-17 : 15:42:44
|
| Thanks for help. I forgot GROUP BY DateT |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|