Score:-1

how to design a sql query to have sub-columns in the result?

us flag

I tried several sql queries but it does not meet my expectations because in the result I cannot have sub-columns

i need to design a sql query for the following result (have sub-columns in the result):

https://i.stack.imgur.com/rkUV8.jpg

How is it possible?

Score:1
ua flag

If you are referring to the column age having min_age and max_age, then use 2 columns with names like that. Here are some further tips.

WHERE age BETWEEN min_age AND max_age

CONCAT(min_age, '-', max_age) AS 'AgeRange'
Score:0
us flag

I found a solution using matrix in ssrs. it concerns the presentation of data

Score:-1
cn flag

You do not. If you read any book on SQL the fundamental thing is that it can not have column hierarchies. The result is one simple table. Now, you can easily generate the data in the picture in columns that are not sub-columns - just combine the parent and client name - and then the only way is to make them sub columns outside of SQL. You need to understand that a table has no concept of a sub-column - what you see there is a visual representation. If your SQL is rejected because you cannot make this in SQL - someone needs a brain good enough to learn the basics of SQL. Cars do not fl. Sub columns are not a table thing.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.