Pridať komentár

Príspevok, na ktorý odpovedáte

Re: SQL select case 31.03.2010 | 19:13
GeoRW   Návštevník
no ta query je nejaka divna; miesas tam groupovacie funkcie (WHEN (COUNT(*) = 0) THEN 1 ) a output pre jednotlive riadky (WHEN (string = ?) THEN (SELECT number FROM test WHERE string = ?)); to by som rad vedel, ze na akej databaze ti tato query zbehne :-)

Neviem, ci sa trafim, ale asi to chces takto
SELECT
  CASE
    WHEN (SELECT count(*) FROM "TEST") = 0 THEN 1
    WHEN "STRING" = 'aaa' THEN (SELECT "NUMBER" FROM "TEST" WHERE "STRING" = 'aaa')
    WHEN (SELECT min("COUNT") FROM "TEST") = 0 THEN (SELECT "NUMBER" FROM "TEST" WHERE "COUNT" = 0)
    ELSE (SELECT max("NUMBER") FROM "TEST")
  END AS "COLUMN"
FROM "TEST"

BTW, pomenovavat stlpce v tabulke tzv. reserved words nie je dobra prax (preto davam TEST, NUMBER, STRING do zatvoriek)
1 + 5 plus tisíc (číslom)

Maximálna veľkosť je: 2,0 MB