-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Star_Venkat
Message 1 in Discussion

 
CREATE TABLE [dbo].[MAINTABLE]( [COMMENT_ID] [int] IDENTITY(1,1) NOT NULL,
        [PRODUCT_ID] [int] NOT NULL,[COMMENT] [nvarchar](50) NULL,[UPDATED_ON] 
[datetime] NOT NULL, CONSTRAINT [PK_MAINTABLE] PRIMARY KEY CLUSTERED
(        [COMMENT_ID] ASC)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = 
OFF, IGNORE_DUP_KEY= OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON 
[PRIMARY]
) ON [PRIMARY]
GO
Create table SECONDTABLE(PRODUCT_ID int primary key)
GO
ALTER TABLE [dbo].[MAINTABLE]  WITH CHECK ADD  CONSTRAINT 
[FK_MAINTABLE_PRODUCT] FOREIGN KEY([PRODUCT_ID]) REFERENCES [dbo].[SECONDTABLE] 
([PRODUCT_ID])
GO
ALTER TABLE [dbo].[MAINTABLE] CHECK CONSTRAINT 
[FK_MAINTABLE_PRODUCT]<o:p></o:p> 
The end user is getting the problem like,<o:p></o:p> 
'MAINTABLE.UPDATED_ON' is invalid in the HAVING clause because it is not 
contained in either an aggregate function or the GROUP BY clause. 
Any possible solution from the group, 
My solution: Grouping the columns and selecting it as a whole will solve this 
problem 
SELECT PRODUCT_ID, COMMENT, UPDATED_ON FROM PRODUCT_COMMENT GROUP BY 
PRODUCT_ID,COMMENT, UPDATED_ON HAVING UPDATED_ON = MAX(UPDATED_ON) 
Welcoming your valid answers. 
Regards, 
Venkatesan Prabu. J

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to