I am getting the top value and least value from table,table accepting the nulls also.i am able to get the top value but not the low value.
This is my table data:
PostBidId UserId PostId BidAmount
-------------------------------------------------
1691 159 1239
1684 147 1239 100000000000000
1683 147 1239 12345666666
1680 147 1239 6777777
1682 147 1239 900
1681 147 1239 90000000
My top value is 100000000000000
, low value id 900
.
This is my code:
SELECT TOP(1)
BidAmount AS HighestBid, '0' AS LowestBid
FROM
[dbo].[Bids]
WHERE
PostId = 1239 AND BidAmount != ''
ORDER BY
BidAmount ASC
Output is: 100000000000000
SELECT
MIN (BidAmount) AS LowestBid, '0' AS HighestBid
FROM
[dbo].[Bids]
WHERE
PostId = 1239 AND BidAmount != ''
Output is: 100000000000000
, what I am expecting is: 900
.
SELECT MIN (CAST (BidAmount as bigint)) AS LowestBid, '0' AS HighestBid
FROM [dbo].[Bids]
WHERE PostId = 1239 AND BidAmount != ''
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.