Skip to content

Tag: sql-server

PIVOT (without aggregation?) in SQL

I am trying to put together a select statement on some data like the below using TSQL: Table1: Property Detail Record No Surname Smith 1 First Name Anne 1 Title Mrs 1 Gender F 1 Surname Jones 2 First Name Ben 2 Title Mr 2 Gender M 2 Which I am hoping to get results which would appear like this:

Unfold Data by Column

I have a dataset that looks like this (where the codes of ID1 and ID2 can never be the same. So putting them together they are still unique): ID ID1 Name AGE ID2 Primary Secondary 1 1234 Jim 34 1111 Mars A 2 1234 Tom 24 1111 Mars A 3 1234 Rick 55 1112 Mars B 4 2222 Ann 22

SQL query subtable in columns from main query

I have 2 tables with a main table with a unique UUID as index and a sub-table containing the languages of 1 row of the main table. E.g. table_1 uuid code 111-etc 123 222-etc 321 table_1_lang uuid lang_code title 111-etc en english 123 111-etc de deutch 123 222-etc en english 321 222-etc de deutch 321 I want t…