﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Teradata Forums / Teradata  / Teradata Database  / can we use max function in case statement? / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Teradata Forums</description><link>http://www.teradata.com/teradataforum/</link><webMaster>info@teradata.com</webMaster><lastBuildDate>Thu, 20 Nov 2008 10:27:22 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: can we use max function in case statement?</title><link>http://www.teradata.com/teradataforum/Topic11782-9-1.aspx</link><description>You can use analytics group functions :INSERT INTO table1    (   amt )SELECT  CASE             WHEN t2.amt = MAX(t2.amt) OVER()                THEN 0             ELSE t2.amt         ENDFROM    table2  AS t2;</description><pubDate>Thu, 12 Jun 2008 10:17:12 GMT</pubDate><dc:creator>al1_24</dc:creator></item><item><title>RE: can we use max function in case statement?</title><link>http://www.teradata.com/teradataforum/Topic11782-9-1.aspx</link><description>You can use analytics group functions :INSERT INTO table1    (   amt )SELECT  CASE             WHEN t2.amt = MAX(t2.amt)                 THEN 0             ELSE t2.amt         ENDFROM    table2  AS t2;</description><pubDate>Thu, 12 Jun 2008 10:14:41 GMT</pubDate><dc:creator>al1_24</dc:creator></item><item><title>RE: can we use max function in case statement?</title><link>http://www.teradata.com/teradataforum/Topic11782-9-1.aspx</link><description>the query u r tryng to run is syntacticaly wrong....try using thisSELECT			CASE			WHEN	amt = COL_C THEN 0			ELSE	amt		ENDFROM	t2,(SELECT	MAX(amt)FROM	t2) TAB_1 (COL_C).</description><pubDate>Wed, 11 Jun 2008 11:50:41 GMT</pubDate><dc:creator>amit_dwh</dc:creator></item><item><title>can we use max function in case statement?</title><link>http://www.teradata.com/teradataforum/Topic11782-9-1.aspx</link><description>For example:insert into table1(amt)selectcase when t2.amt = max(t2.amt) then 0 else t2.amt endfromTable2 t2i'm getting an error 3504: Selected non-aggregate values should be part of the associated group.Any suggessions please...-Sujatha-</description><pubDate>Mon, 09 Jun 2008 23:06:11 GMT</pubDate><dc:creator>Sujatha</dc:creator></item></channel></rss>