I would like to know how to get the amounts paid for the last two months paid per city ordered per year. If I group by year, city name and two months : select year, nameCity, twoMonths, payment …
Tag: sql
Unique constraint violated while insert
I’m running this code INSERT INTO ADW12_DW.WC_MFG SELECT * FROM ADW12_DW.WC_MFG_bkp; COMMIT; Prior to this, ADW12_DW.WC_MFG was truncated to update column size. So ADW12_DW.WC_MFG is empty before …
SQL multiple SELECTs very slow to run
I have the following query (Postgres) which gives the correct results, but it is very slow. Any ideas how I can make it faster? SELECT DISTINCT(vesselimo), vesselname, (SELECT COUNT(portid) FROM …
Select distinct values from a text column in PgAdmin [closed]
Using pgAdmin4 I imported text files to a table with 13 columns. The table columns are all of type text. The first column, named Date, contains text of dates (YYYY-MM-DD). There are multiple rows …
Why Select Distinct stored ‘As T’ and how to alias?
From this helpful response on another question on stackoverflow.com (How do I count unique items in field in Access query?), the answer contained: SELECT Count(*) AS N FROM (SELECT DISTINCT Name FROM …
SQL unpivoting columns
How to unpivot table: to this: What I have so far is : but this is giving me count for all months. I need this with month number and count value for that month. Values 1-9 could be any numbers. Answer Got it working with
multiple selection in the where clause
I need to do multiple selection in the where clause select * from BATS where REASON in case when :P12_REASON = ‘Rejects’ then (‘online’, ‘offline’) else ” end and case when :P12_REASON = ‘…
Oracle Database Object SQL query
In Oracle Database. There are two object tables SHOPS(S_NUM, S_NAME, TEL). And PRODUCTS(P_NUM, P_NAME, P_VAL, P_PRICE, SHOP_NUM). How to write in Oracle Object SQL language query to get how much there …
Does index on string column impact on where clause when providing only part of string?
Let’s start with example: select title from books where name ilike ‘% of the rings’; If i create index on column title it will upgrade my performance or only if full correct string is provided in query? Answer For a standard index, Postgres should be able to use the index when the like patteā¦
calculating percentage on multiple sql tables
There are 2 tables mobile and web Table name: Mobile Table name: web I need to calculate percentage of users who only visited : mobile, web and both. That is, the percentage of users who are only in the mobile table, only in the web table and in both tables. The sum should be 1. I tried using union but