Tag Info

New answers tagged

0

I made a test case - see below. You want the CONCAT function. mysql> select cname from example; +-------+ | cname | +-------+ | abc | | def | | ghi | | jkl | +-------+ 4 rows in set (0.00 sec) mysql> select cname from example where cname like concat('%', 'e', '%'); +-------+ | cname | +-------+ | def | +-------+ 1 row in set (0.00 sec) ...


1

To get all unique pairs of elements from an array of arbitrary length: WITH a(a) AS (SELECT '{A,B,C,D}'::text[]) -- provide array here , i(i) AS (SELECT i FROM a, generate_series(1, array_upper(a.a,1)) i) SELECT ARRAY[a[i1.i], a[i2.i]] AS pair FROM i i1 JOIN i i2 ON i2 > i1 , a; You can then join to the message table. Without knowing any ...


3

1. Subquery expression You can fix it with parentheses like @a_horse commented: SELECT * FROM test_function((SELECT customerid FROM tableX where id = 1)); But this form is rather error-prone. Nothing in the code guarantees that the sub-select only returns a single row. We don't know whether id is unique and neither does Postgres (unless it looks up system ...


0

I have an idea that MAY cause it: The tables you are showing us are not SELECT * FROM ... are they? I think that in dtr_tbl, the logdate has a time part that is not 00:00:00 and this causes that in the WHERE condition, log_date BETWEEN CAST('03/13/2015' AS datetime) AND CAST('03/23/2015' AS datetime) leads to ie 2015-03-23 8:00:05 between ...


0

Try this: SELECT correct_picks, points, pick_user_id, bp, (bp + points) AS total, user_user_id, username, avatar_date, avatar_width, avatar_height, gravatar, gender FROM ( SELECT COUNT(game.game_id) AS correct_picks, SUM(game.points) points, pick.user_id AS 'pick_user_id', -- Alias to avoid same name with user.user_id (SELECT ...



Top 50 recent answers are included