4 Replies - 388 Views - Last Post: 24 March 2018 - 07:32 AM

#1 hers   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 05-June 16

Min and Max or Range

Posted 22 March 2018 - 01:56 AM

Hi,

I have a table in SQL like so

UId Class
1 Apple
2 Apple
3 Apple
3a Apple
4 Orange
4a Orange
4b Orange
5 Orange

I am trying to get the min and max of the UId column for each class as below.

1 - 3 Apple
4 - 5 Orange

Is it possible to do so, as the UId is varchar.

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: Min and Max or Range

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14578
  • View blog
  • Posts: 58,441
  • Joined: 12-June 08

Re: Min and Max or Range

Posted 22 March 2018 - 06:42 AM

Well that certainly isn't ideal, but yes - you can use a group by with min/max on the varchar id column to get what you want.
Was This Post Helpful? 0
  • +
  • -

#3 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2688
  • View blog
  • Posts: 10,767
  • Joined: 03-December 12

Re: Min and Max or Range

Posted 22 March 2018 - 07:06 AM

is there a reason your identifiers are like that and don't follow a normal convention?
Was This Post Helpful? 0
  • +
  • -

#4 hers   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 05-June 16

Re: Min and Max or Range

Posted 24 March 2018 - 03:38 AM

From all the expert adivces I get here, I think I should not do what I intend to do. As it is a ASP.NET Webforms application using VB.NET, I retrieved all the records from the table, and inserted into a dictionary, then played with it. So now I get the result I want.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14578
  • View blog
  • Posts: 58,441
  • Joined: 12-June 08

Re: Min and Max or Range

Posted 24 March 2018 - 07:32 AM

Odd, I did it with SQL. Well, that ever works!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1