Answer the question
In order to leave comments, you need to log in
Why does Select return fewer columns than it says?
Hello
Please advise.
There is a query
with AAA(A) as (select 1 union select 2 union select 3 union select 4 union select 5)
select
'А01' as "id",
1 as "sensor",
generate_series('2021-07-01 00:00 :00', '2021-07-31 23:59:59', '10 sec'::interval) as "time",
t.status[floor(random()* 4 + 1)::int] from ( select array_agg(distinct AAA.A) as "status" from AAA ) as t ,
round((random()* 400 - 200)::numeric, 2) as "value"
in it - 5 fields should be displayed, but only 4- the last value field is not there for some reason.
If you change the order of the last two fields - and make status last in the list,
But why in the order that I wrote to be displayed one field less? I can't find the reason in the tutorials. Tell me please.
Answer the question
In order to leave comments, you need to log in
The reason is simple. Noodles instead of code. This does not allow you to understand what is what.
Let's format:
with AAA(A) as (
select 1 union
select 2 union
select 3 union
select 4 union
select 5
)
select 'А01' as "id",
1 as "sensor",
generate_series('2021-07-01 00:00:00', '2021-07-31 23:59:59', '10 sec'::interval) as "time",
t.status[floor(random()* 4 + 1)::int]
from (select array_agg(distinct AAA.A) as "status" from AAA ) as t ,
round((random()* 400 - 200)::numeric, 2) as "value"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question