Category "sql"

MYSQL not getting the sum zero values (having no entries of that id) against distinct id of another table

SELECT d.millid, d.bookno, d.partyname, d.count, d.counttype, d.orderqty, d.dispqty, d.pending from ( SELECT b.millid, b.count, b.counttype, b.bookno,

Slow MySQL query on 2mill record table despite indexes

Struggling to understand why my query is taking ~8-12s to complete when my table has millions of rows. I can force it to use a specific index, and depending on

Compare date filed with month and year in Postgres

I have a date field in one of my tables and the column name is from_dt. Now I have to compare a month and year combination against this from_dt field and check

create shema databse using XSD in mysql

I have a shema database in file type XSD this file contains descriptions of all tables. My question is how I can use this file to create a database in MySQL. i

Redshift split single dynamic column into multiple rows in new table

With a table like: uid | segmentids -------------------------+---------------------------------------- f9b6d54b-c646-4bbb-b0ec

Getting the "size" of a view in Redshift

Essentially, I'm trying to figure out the size table foo will be after executing: CREATE TABLE foo AS ( SELECT * FROM my_view ); My gut tells me that the

Redshift split single dynamic column into multiple rows in new table

With a table like: uid | segmentids -------------------------+---------------------------------------- f9b6d54b-c646-4bbb-b0ec

ORDER BY field from a comma separated subquery

I'm trying to order a query based on the comma separated result of another query SELECT t.field1, t.field2 /*, ...*/ FROM table t /* ... */ ORDER BY CASE W

Why DISTINCT keyword is decreasing my search time and increasing performace in SQL Server

I am new to SQL and SQL Server and I am using SQL server 2012. but recently I encountered a weird thing while working with SQL server. I got that adding DISTINC

Meta Recruiting SQL -- Join Part 1

I have done my best to neatly format the meta recruiting question below. My current query that I'm trying to ascertain the ratio is this. Returning correct 2/3

how to reference a macro list in a filter of sas query editor

Hello Stackoverflow community. I need to insert a filter into SAS Enterprise Guide query builder. This filter should contain a huge list of product codes, the f

How to INSERT now() + INTERVAL in Postgres 9.x

I'm trying to INSERT a future date into a timestamp with time zone column in a table in Postgres 9.6.2. I'd like this date to be the current transaction time pl

How to INSERT now() + INTERVAL in Postgres 9.x

I'm trying to INSERT a future date into a timestamp with time zone column in a table in Postgres 9.6.2. I'd like this date to be the current transaction time pl

How do I find yesterday's date

I'm stuck on a query regarding dates in Big Query using SQL. I have a table that consists of customer_id (int), date_purchase (date), sales (int). The query is

No suitable driver found for jdbc by Java 9.0.4 and Derby 10.14.2.0 and Maven

I'm trying to solve the problem with connection to Derby since a few days. I have always the same Exception: java.sql.SQLException: No suitable driver found

ASP.NET Exception Error From SQL Server Windows Authentication Login

I have read and tried all the suggestions from [https://stackoverflow.com/questions/22415319/system-data-sqlclient-sqlexception-login-failed-for-user][3] But no

ORA-12015: cannot create a fast refresh materialized view from a complex query

I am using below query to build a materialized view. CREATE MATERIALIZED VIEW gcms_business_profile_mview BUILD IMMEDIATE REFRESH FAST WITH PRIM

Rank actors with movies released in India based on their average ratings. Which actor is at the top of the list?

-- Note: The actor should have acted in at least five Indian movies. -- (Hint: You should use the weighted average based on votes. If the ratings clash, then t

UsageError: Line magic function `%%bigquery` not found

I am very new to Big query. I am trying to load data from a Big query table to pandas dataframe. I followed the syntax given in the documentation here. Unfortun

SQL AVG Alias with CASE

I am trying to run this query, but facing an unknown column error for Average: SELECT CAST(AVG(Lesson_CLass.T_Points) AS Decimal (10,0)) AS Average, CASE