Skip to content
Advertisement

Tag: select

Redshift casting decimal to decimal

Why does casting a decimal to decimal lose all decimals? For example, Returns 2 Answer A decimal number has a precision (the total number of significant digits in the whole number) and a scale (the number of decimal digits). In Redshift, the default precision is 18, but the default scale is 0, and automatic rounding is applied when casting, as

Converting month name to month number in SQL Server

I have a column (says Period_name ) that accepts varchar value. Inside the column, I have inputs likeJan-19, Feb-19, etc. I need an SQL instruction whenever left of Period_name comes like Jan, Feb then it should convert into corresponding month number. For example Input Output The SQL query condition is as follows: Thanks 🙂 Answer Just another option is to

Which join or approach to use

I have two tables. First table contains names of individual teams and teamID which is PK. Second table contains details about matches: homeTeamID, awayTeamID, result. I somehow need to combine these two tables in which I would have names (not IDs) of home and away team and the result of a match. How to achieve this? First table looks like

Difficulty filtering by Select Column

I’m going to apologize in advance. I basically stumble through SQL as projects need done but my knowledge is rather lacking, so I apologize for any incorrect terminology or poor syntax. I would appreciate it if anyone would be able to help me out. I have the following query. I have also attached pics of the current Output and the

Create a View in SQL with a Concatenated Column > Then use Case Statement to affect values

I created a view with a concatenated column named DisplayName, using the code below. Is there a way to change specific DisplayName values using a case statement (or a better method) Something like: case when DisplayName = ‘Robert Jones’ THEN ‘Bob Jones’ when DisplayName = ‘Thomas Simms’ THEN ‘Tommy Simms’ or when FirstName = ‘Robert’ AND LastName = ‘Jones’ THEN

Simple Postgres query returning no result

I have two tables: and I have indexes on id in both tables, and an index on website_id and product_id on the adjustments table. This query returns data but it takes some 5 seconds with some 1k products and a couple hundred in adjustments: This other query however returns no results when there’s nothing in the adjustments table: Was it

Constant field has to be set MySQL

Attribute ‘Territory program’ is a constant field and has to be set to ‘Territory and Quota Program’ constant in result set, I don’t want to add a new column in table, so how can I do that in my select statement if possible? Also I have a column Status… not distributed – if data exists but not distributed to employee

Advertisement