Create a field in sql query results?
-
i have two columns in a sql table that i need to perform math on (qty max - min onhand) during a query and display the calculated results in a field with the query results. i am using microsoft sql server management studio express to complete this. I have no clue how to create custom fields to query results.
-
Answer:
SELECT ... qty_max - min_onhand AS MyField ...
Kevin K at Yahoo! Answers Visit the source
Other answers
The prev answer is basically correct, assuming that those are the actual field names. If you meant that they were the results of the MIN/MAX functions, then it'd be something along the lines of SELECT someID, MAX(qty) - MIN(onhand) AS "Weighted value" FROM someTable GROUP BY someID
Hey friend, I happen to know a really nice tool which solves SQL management problems and more. you should check it out. Cheers, Daniel
Related Q & A:
- How can I optimize this dynamic SQL query in oracle with PL/SQL?Best solution by docs.oracle.com
- Can I create a second filestream container on an existing SQL Server 2008 database without going offline?Best solution by Database Administrators
- How to convert sql query to Hibernate Criteria query?Best solution by Stack Overflow
- How to output XML from a regular SQL query?Best solution by Stack Overflow
- How to convert a SQL query into hibernate criteria?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.