• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

Sql 200 min value

I am trying to return the min value of from a column.  The query is below...

INSERT INTO @ORIGCOUNT
    SELECT ITEM,LOC,WHSE,MIN(TAG_NUM)
      FROM  ENS_PHYINV
      WHERE SHEET_NUM IS NULL
      AND TSUMS IS NULL
         AND CNT_STAT = 'C'
         GROUP BY ITEM,LOC,WHSE,TAG_NUM

The results are not what I expected...below is what it returns...


R89C0001002      Stock      PA      500211
R89C0001002      stock      PA      500212

Why will it not return the first result set?
0
steven
Asked:
steven
1 Solution
 
ste5anSenior DeveloperCommented:
Your statement does not return any rows, cause it's an INSERT statement. But when you refer to the SELECT clause not returning one row, then it's your GROUP BY clause. Remove TAG_NUM from it.
0
 
stevendeveloperAuthor Commented:
Thank you for your help, i didn't explain it properly i ran the query and only wanted the min tag num one row inserted...  Thanks again for the help
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now