Skip to content
Advertisement

Duplicate Primary Key in PostgreSQL table

I created a table named ‘link’ in PostgreSQL database. Then I created another table ‘link_copy’ with same structure as ‘link’ CREATE TABLE link ( id select PRIMARY KEY, url VARCHAR(255) NOT NULL, …

Using 2 “Group By” in one SQL Query

I got 3 tables that look like this: Locations: id,name Events: id,name,locationid Participants: id,name,eventid What I want is a query, that returns all locations, a count of the events linked to it and a count of the participants (indirectly) linked to a location. This is what I’m trying, but this query returns a row for each tournament, instead of grouping

How do I update a table with old value + the new value?

I have this SQL string which updates a row if it exists or creates a row if it does not, how do I do if it updates ctc_portfolio_coins_amount If I have a value of 100, or -100, how do I either substract it or add it to the current value when it updates? Table: Answer Arithmetic: The reference to ctc_portfolio_coins_amount

MSSQL Compare two tables row by row

I am trying compare the results of two select statements row by row. So for example the table looks like the following: GUID | NUMBER (auto inc) | VERSION (timestamp) | Name A | 4 |…

Deleting Part of a string in HIVE

I am trying to delete a part of a string in HIVE. I want to delete the last eleven characters for all records in a column. The data looks like: 1018492743|0001-01-01 I want it to look like: 1018492743 The code I have tried looks like: Select right(a.ord_id, len(a.ord_id)-ll) It isn’t working because len isnt a function in HIVE Another issue

Use NVL with string in Django?

On a Django app, I’m using cx_Oracle to display a roster of sports players: def get_players(self, sport_code=”, term=0): “”” :rtype: object “”” con = cx_Oracle.Connection(settings….

How do I pull last 5 entry from a from a table through SQL query?

I have a table with data entry like below. I want to select the last 5 rows all the time when new data will be inserted. So, product_id 2-6 will be selected in here. But when I will enter a new product, id 3-7 will be selected and afterwards.. What will be SQL query for this? I am newbie. Any

Advertisement