Skip to content
Advertisement

One value for a group of columns in sql

I have the columns like this, all columns coming from three different tables. i want the columns like Can you help me with this? Thanks Answer i am just enhancing Tim answer by adding lag() window function DEMO

How to grouping postgresql when id is same into new add value

I have table like this: And I would like to bring value item in one row when user_input_id and question_id is duplicate. The result that I wish is this: Can anyone tell me how to querying it? Thank You Answer You can easily do taht with string_agg(value,’,’) in postgresql. Output: You can also have array_aggr() in postgres: Output:

How to find which field is giving data type error in QUERY

I have the query report for user but have some error message display: Error converting data type nvarchar to bigint only one message. How to find which field is giving data type error in query? Anyone can give advice? Many thanks! Answer As you have not provided data, it looks like you have NVARCHAR datatype, which is not implicitly convertable

Finding top 10 products sold in a year

I have these tables below along with the definition. I want to find top 10 products sold in a year after finding counts and without using aggregation and in an optimized way. I want to know if aggregation is still needed or I can accomplish it without using aggregation. Below is the query. Can anyone suggest a better approach. Sample

How to get custom separators in SQL Server query

I have a table in SQL Server that looks like this If this table was in Oracle and I wanted to get all the properties separated by different separators then I would write something like this I would get output like this Notice all the separators are different. How can I write a similar select statement for SQL Server? Answer

Advertisement