Category "sql"

What does "EXCEPT distinct select * " in SQL language mean?

I am following a tutorial on Qwiklabs on Bigquery and financial fraud detection and came across a query, below, that I am failing to understand CREATE OR REPLAC

Missing comma before start of a new alter operation. (near "CHARACTER SET")

Mysql - phpmyadmin What's wrong with this query? ALTER TABLE `invoices` CHANGE `status` `status` ENUM('paid','due','canceled','partial','cheque') CHARACTER SE

GROUP by multiple ranges in postgresql

I have max and min values of prices in postgresql, and group the count of result set according to different ranges of prices between this max and min values, my

Order of execution Oracle Select clause

Consider a query with this structure: select ..., ROWNUM from t where <where clause> group by <columns> having <having clause> order by &

How can Select date(dd/mm/yyyy) in ascending order in sql

I want To Select stockDate in ASC Order My Table Structure is.:-

PYODBC--Data source name not found and no default driver specified

import pyodbc connection = pyodbc.connect('Driver = {SQL Server};Server=SIWSQL43A\SIMSSPROD43A;' 'Database=CSM_reporting;Trusted_Con

Postgres Subquery - How to create ALIAS in object format from subqueries

I am trying to wrap several queries into 1 complex query. Here is the scenario. Given a user_id of 'xxxxx-xx-xxxxx' I have to query for several data points with

ORDER BY Not Working in JPQL Query

I have the following method that returns a HashMap based on a Users Department and Building. I want to ORDER BY ASC based on the user name private HashMap<L

Changing values and Concatenating into readable Dates

I have 2 columns called MONTH, and YEAR. The YEAR is just pulling in as INT and contains values such as 2017 2018 2019 etc... The MONTH column however is pul

Make calculations across multiple tables based on the table suffix in Bigquery

I have a database of daily tables (with prefixes formatted as yyyymmdd) with customers info, and I need to get a 90 day timeline of 90 day ARPUs (average revenu

how to find difference between no_of_value and no_of_distinct columns values?

Let be the number of CITY entries in STATION, and let be the number of distinct CITY names in STATION; query the value of from STATION. In other words, find

UninitializedPropertyAccessException in Android Studio using Kotlin

I am a beginner making use of a Roomdatabase. Mostly using it to load in and pass items between tables using simple relationships. package com.example.allin

Deterministic sort order for window functions

I've a status table and I want to fetch the latest details. Slno | ID | Status | date 1 | 1 | Pass | 15-06-2015 11:11:00 - this is inserted first 2

Transpose rows to columns in PostgreSQL?

Does any one know how to transpose rows to columns in PostgreSQL? For example I have the following table:- Period T1 T2 D

Oracle SQL LAG() function results in duplicate rows

I have a very simple query that results in two rows: SELECT DISTINCT id, trunc(start_date) start_date FROM example.table WHERE ID = 1 This results in the fol

How can I convert an integer representing EPOCH time to a timestamp in Athena (Presto)?

I have a table where the datetime is stored as varchar but represents the EPOCH time (e.g. 1556895150). How can I get that value to be recognized as a timestamp

How to minimize transaction log sqlserver database .?

I have database size is more than 125 GB . and every 1 hour the database is not respond . the message is every time say (The transaction log for database MESP_2

calculating each day sum and last 7 days sum for max date to last 7 days and 14 days and 21 days sum in new columns

I have the following data set: which is daily sum. Based on this, how do i get last 7 days sum, 14 days sum and 21 days for each row in new columns. I have trie

Inserting aggregates into big table is too slow

I need to run a query as cronjob and it is too slow to perform. It sums a value from a view table (data_time_series) for each pair of aks and ii and inserts a r

How to get the first field from an anonymous row type in PostgreSQL 9.4?

=# select row(0, 1) ; row ------- (0,1) (1 row) How to get 0 within the same query? I figured the below sort of working but is there any simple way? =# se