I have a table like this I want to select the top 3 total by groups. How can i do it? Answer In most [big data] use cases using ROW_NUMBER() is not fine as it ends up with resource exceeded error. This is because it requires all point of same group be present in same/one node which in case of
Tag: sql
MS-Access Query to PostgreSQL View
I am converting a microsoft access query into a postgresql view. The query has obvious components that I have found reasonable answers to. However, I am still stuck on getting the final result: …
Getting Foreign Keys as separate columns
i’m not really much of an expert when it comes to databases and i was wondering if it’s possible to do something which might be a little weird I’m having a simple table called options which has 3 …
SQL Server 2014 – Show record even if zero (General Ledger reporting)
I am creating a General Ledger report for the finance team. I have a list of all transactions by calendar Month. Of course some GL codes are not used every month for whatever reason. I do have another …
Fetching Results after ibm_db.execute()
Take a look at the following code: import ibm_db #Authentication Details f=open(r”C:UsersXXXXXMy Code.rc”,”r”) lines=f.readlines() us=lines[0].rstrip() pd=lines[1] sql_file = “NNM_SQL.sql” f = …
I don’t know how to combine my attributes into a single column for this query
My query is to Produce a list of Employees who work for the cinema with the cinema number 07 and include the cinema name in the result. Arrange the result in ascending order by employee surname. Name …
Return multiple tables specific to each column
I would like to get a more simple query that runs through all columns of a table and returns the SAME number of tables for EACH column. For example… select distinct a from tbl; select distinct b …
SQL Order by 2 conditions
Let’s say that I have a database, that looks like that: price date hour 12.00 2018-12-11 5 13.00 2018-12-04 2 14.00 2018-12-06 1 15.00 2018-12-11 1 16.00 2018-…
Postgres 10 sql How can I do distinct without all columns
I have this following query that gets the closest cities/town to a certain coordinate that is passed in . It will return a max of 5 records and I only want to do a distinct on city and state . In the …
SQL: Sort rows based on attribute order
I want to sort an the value of an attribute (called position) to the row number of another attribute’s ordering. Example: If I have the following attributes: position, points I’d like to order the …