New answers tagged

1 vote
Accepted

How to query two tables and get the rows from one mask the ones from the other?

SELECT CASE WHEN t2.data IS NULL THEN t1.id ELSE t2.id END id, idpersona, data, CASE WHEN t2.data IS NULL THEN t1.settimana ELSE t2.settimana END settimana, CASE WHEN t2....
Akina's user avatar
  • 19.7k
1 vote

How to query two tables and get the rows from one mask the ones from the other?

Maybe I've found a solution. The idea is to build an UNION without some rows from the main table. Those rows are identified with an INNER JOIN matching dates and person IDs. SELECT id, ...
Daniele's user avatar
  • 113
1 vote

Select last record of every hour, but time is not precise

I found a solution. Maybe is suboptimal, but suits my needs... SELECT T.* FROM electric_meters AS T JOIN ( SELECT MAX(ts) as ts_max, DATE_FORMAT(DATE_ADD(ts, INTERVAL 55 ...
Ajax's user avatar
  • 111
0 votes

Select last record of every hour, but time is not precise

If window functions are supported in your version, you could try select `id`, `ts`, `id_sensor`, `value` from ( select `id`, `ts`, `id_sensor`, `value`, row_number() over ( ...
Alexander Peresypkin's user avatar
1 vote
Accepted

Moving records between tables in CockroachDB is taking too long

In CockroachDB, doing an INSERT INTO <table> SELECT * FROM <other_table>; operation is generally a bad idea. I would suggest using CREATE TABLE AS syntax (https://www.cockroachlabs.com/...
jhatcher9999's user avatar

Top 50 recent answers are included