Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql 200 min value

Posted on 2014-12-23
2
Medium Priority
?
146 Views
Last Modified: 2014-12-23
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
Comment
Question by:steven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
ste5an earned 2000 total points
ID: 40515146
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
 

Author Closing Comment

by:steven
ID: 40515233
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question