Jump to content

BillWestman

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BillWestman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Looks like the Greatest function is not supported in TD sadness. so far this works - but any advice about a 16 category solution would be helpful. SELECT id, CASE WHEN category_1 > category_2 AND category_1 > category_3 THEN category_1 WHEN category_2 > category_3 THEN category_2 WHEN category_3 IS NOT NULL THEN category_3 ELSE 'NA' END AS MaxScore, CASE WHEN category_1 > category_2 AND category_1 > category_3 THEN 'category_1' WHEN category_2 > category_3 THEN 'category_2' WHEN category_3 IS NOT NULL THEN 'category_3' ELSE 'NA' END AS MaxScoreCategory FROM yourtable
  2. SQL wizards: I have a query which needs to be written as with left joins so it will work with TD 12 (scalar subqueries do not work). Here it is: Thank you in advance for looking and hopefully soliving. Currently the following yields: SELECT Failed. 3706: Syntax error: expected something between '(' and the 'SELECT' keyword. No explain available. select id, (select case when Category_1 = b.MaxScore then 'Category_1' when Category_2 = b.MaxScore then 'Category_2' when Category_3 = b.MaxScore then 'Category_3' else 'NA' end from myTable t where t.id = b.id ) as MaxScoreCategory, MaxScore from ( select id, max(Score) as MaxScore from ( select id, 'Category_1', Category_1 from myTable union all select id, 'Category_2', Category_2 from myTable union all select id, 'Category_3', Category_3 from myTable ) a(id, Category, Score) group by id ) b
  3. I have two tables with IDs (millions) - probably this is simple but I can not figure it out. (thank you in advance!) table 1 id 1 2 3 4 55 table 2 id 1 2 3 4 5 6 what I would like is a query that returns all of the matched and the unmatched Ids in ONE ROW table 3 id 1 2 3 4 5 6 55 *** Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.