Postgresql – SQL – Find common rows
I have a table Wallets: [id] [address] 1 ABC 2 ABC 3 DEF 4 GHI 5 JKL I have a table Cards [company] [color] [wallet_id] Facebook blue 1 Facebook blue 2 Youtube red 3 Facebook blue 3 Orkut pink 4…
I have a table Wallets: [id] [address] 1 ABC 2 ABC 3 DEF 4 GHI 5 JKL I have a table Cards [company] [color] [wallet_id] Facebook blue 1 Facebook blue 2 Youtube red 3 Facebook blue 3 Orkut pink 4…
How can I update and change only the time-section of a CURRENT_TIMESTAMP in postgres SQL? I have to INSERT INTO a TABLE a new VALUE with the CURRENT_TIMESTAMP to get the correct year, month and day. The Time needs always…
I've got a table containing results of chess matches: id player_white player_black result session_start session_end 1 Jonathan1 TrentX 0 2020-01-01 13:10:10 2020-01-01 13:15:23 2 TrentX Jonathan1 1 2020-01-01 13:18:32 2020-01-01 13:23:13 3 Ezekiel2001 Jonathan1 1 2020-01-01 13:30:12 2020-01-01 13:37:01 4…
Sorry for the vague title, but I don't know how to word this type of problem better. Here is a simple example to explain it. I have to tables: OrderItemList and OrderHistoryLog. OrderItemList: |------------------------------| | OrderNo | ItemNo | Loc…
I log the daily produced energy of my solar panels. Now I want to create a SQL statement to get the sum of produced energy for each month but separate columns for each year. I came up with the following…
I have a table that has columns Name, Series and Season. Name series season abc alpha s1 abc alpha s2 pqr alpha s1 xyz beta s2 xyz gamma s3 abc theta s1 I am trying to extract the number of…
cur.execute(""" CREATE TEMPORARY VIEW bobby_view AS SELECT heading1, heading2 FROM bobby WHERE heading2 = %s; """, (variable,)) cur.execute(""" SELECT d1.heading1 FROM bobby_view d1 WHERE d1.heading1 >= ALL ( SELECT d2.heading1 FROM bobby_view d2); """) answer = cur.fetchone()[0] This produces the…
Please let me know how to get this output, I have searched a lot but all of the queries shows two separate tables one for employees and another department. Here I do not have it so I tried this: SELECT…
I have a table called traffic shown below. I have to write a query which list all the protocols for which incoming traffic is higher than outgoing. The result should be in this format - protocol, traffic_in, traffic_out and sorted…
I use the following code to create a table if it does not exist yet: PGconn* conn; PGnotify* notify; PGresult* createTableRes; createTableRes = PQexec(conn, "CREATE TABLE IF NOT EXISTS t_xyz (xyzId SERIAL PRIMARY KEY NOT NULL, xyz VARCHAR(100) UNIQUE NOT…