Skip to content
Advertisement

Tag: sql

Teradata SQL help. Need help getting the start date and end date (yellow) of the most recent employment status. Thank you

Teradata SQL help. Need help getting the start date and end date (yellow) of the most recent employment status. Thank you. Click on the question for image. Answer There are several ways to get your expected result, based on your data you might apply Teradata’s NORMALIZE option, a SQL extension to combine overlapping periods: Caution : This returns a new

Member’s books in possession in Library System

Hello I am currently working into a library system and I do want to view how many books are in possession of a specific member. I want to add a copies to student whenever I issue a book to them. I have tried: but it doesn’t insert into members row, instead it shows I have also tried: But doesn’t work

SQL Recursive Count

I have two tables I am joining with the following structure: A ContentDivider can have n ContentDividers as Children and can have m CustomPages as children as well. I want a View that counts the Display the current CustomDivider and the COunt for all the CustomPages as Children of the current ContentDivider. My Test data: And the View I want

SELECT to return duplicate distinct column values

Tying to have query that can duplicate some column values based off values in other columns. ID1 column will always have a value and ID2 and ID3 may or may not. Data in table looks like this. Wanting to to query this table to show resultset like this Been stabbing at this trying case selects, and inserting into temp tables.

How to select count of 0s, 1s, and both 0s and 1s in a postgres table column?

Say there’s a table that has columns named binary_value, name, and created_at along with the id column. Here’s the SQL Fiddle for this question: http://sqlfiddle.com/#!15/d15d1/36 What would be an efficient query to get a result like the following? So far, I’ve got: Which gives it in column form: How can we get the result in a row? Perhaps there’s a

How can I join result from two queries

So sorry but I am new to SQL querying and could use a little help. I will like to join results from 2 tables and I can’t seem to get it return results I need. Query 1 Query 2 I tried using union all but I get an error must have equal number of expressions in their target lists. Any

Replace function in SQL Server

I have a string of data I am trying to use the replace function to replace double commas with NULL values Solution But I keep ending up with (The ,,, needs to become ,NULL,NULL, but only becomes ,NULL,,) Here is my sample code I’m using Answer If you do the same replacement twice, any number of sequential commas will get

Advertisement