I aim to list the forth generation of a family using SQL Server. Example family tree in the picture (id based) FAMILY TREE The tables I have are: Family +——+—————–+ | f_id | f_name …
Tag: sql-server
How can I pull out the second highest product usage from a SQL Server table?
We have a product usage table for software. It has 4 fields, [product name], [usage month], [users] and [Country]. We must report the data by Country and Product Name for licensing purposes. Our rule …
Return Data based on Column
I am modifying a current query which returns n amount of rows. I would need to return the same amount of rows but with one more column of data. I have two sql tables shown below. Products and Product Attribute Values. When i run this query i get a few 1000 rows back. But when i run this query I
What do the quotes mean in this SQL Server snippet? (SELECT ” column1, ” column 2)
I’d like to know the purpose of the two single quotes in front of each column. This is in a stored procedure. Thank you for your help! Answer The expression ” is an empty string. So this is using an empty string instead of NULL for “missing” values. I would write this code as: This mig…
Get Row based off Date and previous row
I’ve got the following sample data and what I’m trying to do is based off the DateChanged value is get the appropriate Amount from the linked table along with the previous row. The results would then display as How could this be done? What I have so far is this but wondering is there’s a bet…
Define two or more conditions into a stored procedure with inner join?
First, I needed to filter the data from the tables TbTaxCompanies and tbCompany, through the variable @company_id… and works! And second I need to filter again the set of logs from the company selected previously with @company_id, but now to obtain only the latest updated taxes (only one row)… and…
Grouping with order in complex data
I have data like this Name valuta price Type Type2 A USD 10 Acc 1 B USD 30 Acc 2 C SGD …
How to comapre two rows in SQL Server
Consider the below rows in a table I want to compare two rows and get difference between them. My required result would be: Answer …adjust..
Column to see Completion
I’m trying to come up with a way to add an extra column to this result-set that is a bit value of 1/0if the particular owner has all the rows as not null. The column would be: Answer You can use window functions:
How to convert char data type to date in SQL Server?
In a table, there is a column BeginDate of type char(10) and all the records are saved in 2020/05/06 format. How can I change the data type to Date? Answer You could strip the / characters and then you have the ISO format yyyyMMdd.: But the real solution is fix your design; stop storing dates as a varchar.