1
SELECT x, y, z FROM table_one
WHERE y='asd'
ORDER BY z ASC;

Hi, I'm querying my database using the query above, upon the return of the query I'd like to increment z by 1 (not update it but just increment it so it shows in the result). I don't want to do an Update statement, this is just temporary and should only be visible in the query result.

How would I go about doing this? It's for a school assignment. I've tried to use REPLACE without any success. What works is changing z to z+1 but then the column name changes to ?column? instead of z.

Any help would be appreciated!

2
  • 2
    you can say z+1 as z Commented Apr 14, 2018 at 16:27
  • @VamsiPrabhala Yeah, Googling for 30 minutes led to nothing, and it was this simple. Thank you, worked great! :) Commented Apr 14, 2018 at 16:29

1 Answer 1

3

You need add column alias:

SELECT x, y, z + 1 AS z    -- here
FROM table_one
WHERE y='asd'
ORDER BY z ASC;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.