Đã Hủy

SQL query help

Job Description:

I need some help how to successfully order my data.

I have a table with the following fields:

ID,

ID_Parent,

Created_At,

...

ID and ID_Parent are not integer but a random 8 number string like xxxx-xxxx

The table holds information for parent and child records. For example

1000-0000 Parent 1

5001-1000 Child 1 of Parent1

3001-2500 Child 2 of Parent1

2529-5000 Parent 2

3501-1010 Child 1 of Parent1

What I want is to order records based on date DESC (Created_at) and display one expanded record set just after the parent record for example. Example #1:

19-Dec-2014 Parent 3

20-Dec-2014 Child 2 of Parent 5

19-Dec-2014 Child 1 of Parent 5

10-Dec-2014 Parent 2

05-Dec-2014 Parent 1

Example #2:

19-Dec-2014 Parent 3

10-Dec-2014 Parent 2

05-Dec-2014 Parent 1

10-Dec-2014 Child 2 of Parent 1

05-Dec-2014 Child 1 of Parent 1

Execute the SQL query to the SQL table attached on this project:

select id, id_parent from order_items

where id_parent = '1077-2649' or id_parent = '0'

order by created_at

you will see its not correctly sorted:

[login to view URL]

SQL data/script Download link:

https://www.sendspace.com/file/g5of2b

Kĩ năng: Phát triển cơ sở dữ liệu, Lập trình cơ sở dữ liệu, MySQL, SQL

Về khách hàng:
( 126 nhận xét ) Petrich, Greece

ID dự án: #8442656

47 freelancer chào giá trung bình€14 cho công việc này

ConnectUsSoft

Between 2009 to Present, I worked as a web application, mobile application and desktop application developer for several employers. In terms of my accomplishments: MVC framework with Entity Framework in .net,Angular Thêm

€14 EUR trong 1 ngày
(30 Nhận xét)
6.3
codetod

Hi I have gone through your requirement and sample data. What I understood is that you need the parent created last as the first rows, then its children, then next parent, his children etc. As far as I know, this is Thêm

€25 EUR trong 3 ngày
(80 Nhận xét)
6.4
m7slabs

A proposal has not yet been provided

€17 EUR trong 1 ngày
(61 Nhận xét)
5.5
mdkass

Hello, I think we worked together before and I'm interested to work again with you. I have good SQL experience and help you doing this small task. Regards.

€13 EUR trong 1 ngày
(48 Nhận xét)
5.5
azmatakhtar

I can discuss this task with you

€19 EUR trong 1 ngày
(28 Nhận xét)
5.1
vinaysinghh

I am sql expert certified by Oracle corporation and having more then 5 yrs of experience in sql Oracle and mysql.. I have already made query and result coming perfect i can send you screen short

€14 EUR trong 1 ngày
(61 Nhận xét)
5.3
point5nyble

Hello, I have been working with a MNC based company since last ~ 5 years, as an IT BI DWH Professional. The project is a BI DWH project which covers 3 layers of BI (ETL, Data warehouse & Reporting) and helped me in Thêm

€19 EUR trong 1 ngày
(46 Nhận xét)
5.2
acronymsolutions

Hi, I am 16+ years experienced Database Programmer at CMMI-5 level company. I am Personally working on : RDBMS : MS Access,Oracle,MySQL, MSSQL Server 7.0/2000/2008R2 and Onwards. Database Tools : Database Configur Thêm

€15 EUR trong 1 ngày
(40 Nhận xét)
5.8
krashmi

A proposal has not yet been provided

€14 EUR trong 1 ngày
(30 Nhận xét)
4.5
yubor

SQL Server expert. Would be glad to help you with this task. Regards, Yuri .

€12 EUR trong 1 ngày
(32 Nhận xét)
4.5
Straust

Look, what you need is the list, ordered by date DESC, showing first the entries which are parents (id_parent 0) AND after the parents, you want the entries which are childs (so, id_parent is something different to 0) Thêm

€15 EUR trong 3 ngày
(2 Nhận xét)
4.5
softtechsurat

Hello sir/madam, we have read and understand your requirement and very much confident that we can complete this project within low budget and less time . Give us chance to serve you better Looking forward to be Thêm

€15 EUR trong 1 ngày
(18 Nhận xét)
4.2
rafaelnadal

Hello I am Software Engineer and Expert in Sql optimization So you can consider me for this Project Thanks I wil wait for your quick Response

€9 EUR trong 1 ngày
(6 Nhận xét)
3.4
koko0o0

Hello Sir, we are ready to start working on your project instant. Feel free to ask us any questions that you have. Thanks and regards!

€12 EUR trong 1 ngày
(6 Nhận xét)
2.9
jperusan

Use this query: select created_at,id,id_parent from order_items where id_parent = '1077-2649' or id='1077-2649' order by id_parent ASC, created_at DESC;

€8 EUR trong 1 ngày
(5 Nhận xét)
2.9
gsanjaykarthik

I have very good SQL knowledge and I can do it in easy way.

€12 EUR trong 2 ngày
(1 Nhận xét)
2.6
k122156

i have experience but i am new here, we can talk if you ping me . thanks ----------------------------------------------------------------------------------------

€14 EUR trong 1 ngày
(0 Nhận xét)
0.0
ahmedseifeldien

Hi I have a good Experience in SQL queries I can do this task in on day With height performance and the shortest way

€15 EUR trong 1 ngày
(0 Nhận xét)
0.0
RoyMun

well, i will explain to you how is going to work, how to achieve that and also training, i need your help to build my portfolio :)

€14 EUR trong 1 ngày
(0 Nhận xét)
0.0
Magination

I m experience developer . I can do what you need . you will have to paid me after your work has been done . Thank you

€12 EUR trong 0 ngày
(0 Nhận xét)
0.0