Category "sql"

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

SSMS Export Query Results to Excel or CSV

I am trying to export the results of a query to CSV and then ultimately Excel. My issue is, one of my columns has commas in it and the commas interrupt Excel

Pivot Multiple Columns in SQL

I want to pivot multiple columns like the table below: Original Table: ID ClientName RegDate Interest AMT Principal AMT 1 A 01-Sep-19 100.0

System.Data.SqlClient.TdsParser' threw an exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format

I am hosting .net core applicaton on server but when I try to run the application it throws exception in windows logs: Unhandled exception. System.TypeInitializ

Rolling 12 month Calculation SQL

I am trying to do a 12 month rolling calculation, but I get a syntax error at "rows", here is what I have so far: (SUM(YTDValue) OVER (ORDER BY PerformanceDate

Create View in SQL Server to create multiple rows for each date,with calculated date and identifier column

I need to create a VIEW/Select statement that will take a start date, and create 3 different rows for each date. One row calculates 30 days, from the start date

Display department names using Cursors.Create a PL/SQL block to display all the department names from the Department table using cursors

TABLE: Column name Data type Constraints DEPARTMENT_ID NUMBER(5) PK DEPARTMENT_NAME VARCHAR2(25) NOT NULL LOCATION_ID VARCHAR2(15) I have tried this. But stil