Concluído

Correct or provide a correct SQL statement for grouping data from single table.

I have a table that has 5 fields.

MyTable (ts int, pid int, pfc int, psc int, spt int)

The table stores unique records. I mean no record will present in the table twice.

The stored data essentially is grouped by the "ts" field.

I mean all the records that have the same "ts" value can be considered a single group.

The task is to write a SQL statement in such a way that we find the frequency of the records with respect to a single group and with respect to the entire groups.

For example:

If we have this records:

INSERT INTO MyTable VALUES (10, 1, 0, 0, 0) ;

INSERT INTO MyTable VALUES (10, 1, 0, 0, 0) ;

INSERT INTO MyTable VALUES (10, 1, 0, 0, 1) ;

INSERT INTO MyTable VALUES (10, 1, 0, 0, 1) ;

INSERT INTO MyTable VALUES (10, 1, 1, 0, 1) ;

INSERT INTO MyTable VALUES (11, 1, 0, 0, 1) ;

INSERT INTO MyTable VALUES (11, 1, 0, 0, 1) ;

INSERT INTO MyTable VALUES (11, 1, 0, 0, 1) ;

INSERT INTO MyTable VALUES (11, 1, 0, 2, 0) ;

INSERT INTO MyTable VALUES (11, 1, 0, 2, 0) ;

The final result of the desired SQL statement is

ts | pid | pfc | psc | spt | thiscount | accmulatedcount

10 | 1 | 0 | 0 | 0 | 2 | 2

10 | 1 | 0 | 0 | 1 | 2 | 2

11 | 1 | 0 | 0 | 1 | 3 | 5 <-- because we have 2 in the 10 group

11 | 1 | 0 | 2 | 0 | 2 | 2

11 | 1 | 1 | 0 | 1 | 0 | 1 <-- NOTICE: thiscount =0 because no reletive record in the group 11 HOEVER the "accmulatedcount" reveals the "1" from the previous records in any. If we have more than groups then we should do the same with them.

For a clear example please see the attached image.

Habilidades: PostgreSQL, SQL, Microsoft SQL Server

Veja mais: store image sql server 2005 table, sql parent child table, windows mobile sql statement, sql aggregate functions, sql max group by, sql view group by, sql group by count, sql group by, select all columns but group by one column in sql, sql group by multiple columns, sql group by sum, mysql, database programming, postgresql, sql parent child table tree query, sql statement excel, sql tree structure table, sql recurring event table, decimal places oracle sql statement, write sql statement

Acerca do Empregador:
( 1 comentário ) SWANSEA, United Kingdom

ID do Projeto: #17525236

Concedido a:

limillion819

Hello sir. I am very interested in your proposal. I can instantly help you with your starting project with a successful completion. SQL is a very friendly language for me and in a few hours, you'll get a wonderful r Mais

£10 GBP em 1 dia
(0 Comentários)
0.0
£21 GBP em 1 dia
(7 Comentários)
3.7

18 freelancers estão ofertando em média £17 para esse trabalho

£19 GBP em 1 dia
(141 Comentários)
6.9
£18 GBP em 1 dia
(4 Comentários)
3.8
£13 GBP em 1 dia
(11 Comentários)
3.9
sachinraghav

Hello There, I have been working with postgresql, sql, sqlite since last 4+ years. I can do your project. I would like to do your project. Message me for more details.

£13 GBP em 1 dia
(6 Comentários)
2.9
brawnyjavier

I have more than 3 years of experience working with databases such as oracle and MSSQL with complex queries

£18 GBP em 1 dia
(0 Comentários)
0.0
webdroid

Hi, It's very simple job according to my expertise so please come to chat i will solve this statement ASAP . Please come to private chat to start working on it right away thanks Please visit our company profil Mais

£28 GBP em 1 dia
(0 Comentários)
0.0
fastwebsoft

hello sir, I have great knowledge in core development and more than 4 year experience. also I can do your task in few hours. thanks

£13 GBP em 1 dia
(0 Comentários)
0.0
deepchopade

I have done task like this before. I can do it confidently. To write the query so that you will get count of repeated int in column and complete table, I have syntax ready.

£18 GBP em 1 dia
(0 Comentários)
0.0
£13 GBP in 0 dias
(0 Comentários)
0.0
£18 GBP em 1 dia
(0 Comentários)
0.0
PARMOD89

Hey I have read & understood your requirements. I have already done similar kind of jobs. I have plenty of time available with me. So i hope you will open a PM for discussion. Thanks Parmod

£18 GBP em 1 dia
(0 Comentários)
0.0
£13 GBP em 1 dia
(0 Comentários)
0.0
antaresfa01

hi I am experienced developer and i need good feed back because i am new to freelancers. i m bidding very low for feedback only.

£13 GBP em 1 dia
(0 Comentários)
0.0
qousainhaider

Hello there i have been working on tsql from a long I believe i can do your task real quick.

£21 GBP in 2 dias
(0 Comentários)
0.0
charlie02

Hi there, I have right experience to do this job. Do inbox me for further discussion. I am working on sql server from 4 years. Thanks

£18 GBP em 1 dia
(0 Comentários)
0.0
£13 GBP em 1 dia
(0 Comentários)
0.0