Skip to content

Get last record from joined table

I have two tables DOCUMENT and SIGNATURES, like below And I’m try to get last signature name. I have a SQL FIDDLE with database and query, but when run search no record has found. http://sqlfiddle.com/#!9/b98474/3 Here my query Answer A simple method is a correlated subquery: With an index on signatures…

SQL Check if the User has IN and Out

I need help getting the User which has an ‘IN’ and ‘Out’ in Column isIN. If the user has an IN and OUT do not select them in the list. I need to select the user who has only had an IN. Please I need help. Thanks in advance. This is the table: Need to get the result like I

SQL total for each row combination

Are there any types of aggregate functions that could help calculate the following? If I have the following data, I want the sum total for each duplicated row. The output would provide total number each row occurs: Answer Why not good old group by and count?

Include Column name in SQL Unpivot

I have an unnormalized data set I need to normalize for reporting purposes. I successfully unpivoted the data using this: How can unpivot column headers Question1, Question2, Question3, Question4 as a third column in my unpivot query, like this? Answer Your syntax looks like SQL Server. If so, just use a APPL…

PostgreSQL simply transpose/convert rows to columns

I read some SO posts like sql server 2008 r2 – Transpose rows to columns – Stack Overflow or sql – Postgres – Transpose Rows to Columns – Stack Overflow, but they are too complicated task to what I want to implement, and what I want to is pretty simple task. For example, assume I…

Is this possible to calculate this?

Is this possible to store the decimal type value in number column. 1/12 will be 0.083 and wants to store that in that column. create table test(number1 int,number2 int,number float) insert into test …