Quantcast
Channel: Run multiple, expensive, single result queries and return a single row - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 2

Run multiple, expensive, single result queries and return a single row

$
0
0

I have a lot of fairly large datasets in a MS SQL table, and I want to get a bunch of data about.

For example, let's say I have

NameAgeHeightWeightGenderCountry
Person2318679MaleGB
Person12517265MaleUS
Person22718679FemaleGB
Person31918768FemaleGB

And I want to go off and query to get the oldest male, the tallest male and heaviest male which were uploaded today. E.g. something like

select top 1 name, height from 'people' where country = 'GB' and gender = 'male' order by height desc;select top 1 name, age from 'people' where country = 'GB' order by age desc

Note, I don't need to return the row, I just need to return the person and each SELECT will only return one row.

I'm currently running many, individual, SELECT statements but these are very expensive as I have to connect to the DB each time and the process the result.

So, ideally, I would like to merge the results of them all to return:

OldestTallestHeaviest
PersonPersonPerson

Is this possible?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images