Assign values to sorted result in SQL [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have got table like below after sorting in SQL:
M_ID
-----
2013/01
2013/02
2013/03
2013/04
2013/05
2013/06
Now I want to assign each entries a particular value like below
M_ID Days
--------------
2013/01 20
2013/02 30
2013/03 40
2013/04 50
2013/05 60
2013/06 70
So, can you please let me know how to do that in SQL Query?

Do you mean something like this (presuming sql-server)?
SELECT M_ID,
Days = (ROW_NUMBER()OVER(ORDER BY M_ID) + 1) * 10
FROM dbo.TableName
Demo

Related

Counting word frequency [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to sum the frequency of the words cumulatively in PostgreSQL
Here's my table (example)
I need sum accumulative frequency for same words, for example the expected results is:
resize (100 + 85) = 185
trabajar (75 + 73) = 148
partir (64) = 64
How can I make the query?
you need to use GROUP BY :
SELECT
word
, SUM(frecuency)
FROM tablename
GROUP BY word

Oracle SQL Select Only 5 Digit Row in a Column [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
SELECT *
FROM GNGRB.CLAIM
WHERE ZOCRECDT IS NOT NULL;
SLNO Column select only 5 digit row
Please use length function of oracle. For e.g:
select *
from table a
where length(a.column_name) = 5
In your case
SELECT *
FROM GNGRB.CLAIM
WHERE ZOCRECDT IS NOT NULL
and LENGTH(SLNO) = 5

summing up of two rows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Input:
A
-----
5000
4000
-3000
-2000
Output:
A FEEDBACK
----- --------
9000 POSITIVE
-5000 NEGATIVE
THEY HAVE GIVEN THE INPUT. I NEED TO WRITE A CODE TO BRING THE OUTPUT.
I think this query should do:
select sum(a) as a, 'POSITIVE' as feedback from t where a >= 0
union
select sum(a) as a, 'NEGATIVE' as feedback from t where a < 0

query to check multiple revsions on a table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Need a query to check ids with multiple revisionnums
id reviionnum
1 0
2 0
1 1
3 1
2 1
The query should result
id revisionnum
3 1
Please help
If you want ids with only one revision number, you can use aggregation:
select id, min(revissionnum)
from t
group by id
having count(*) = 1;
The min() is the value if there is only one row.

Django get all rows with same value in column [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
how can I filter in Django to get a data row one times if the same value in on column?
columns:
a | b
x | y
a | y
y | s
Want one data row set with y (b) and one data row set with s (b).
If not clear what I mean I edit with SQL script...
EDIT: SELECT DISTINCT b FROM table;
Sorry to be blind...
http://docs.djangoproject.com/en/dev/ref/models/querysets/
Have a nice day.