Find Jobs
Hire Freelancers

Custom SQL Query - complex join

$10-30 USD

Ολοκληρώθηκε
Αναρτήθηκε περίπου 8 χρόνια πριν

$10-30 USD

Πληρωμή κατά την παράδοση
My SQL skills are a bit rusty, and I need some help with a complex query. Here's an example of the table data: Date Column2 Column3 Column4 2016-03-18 A 1000 5.43 2016-03-18 B 1000 2.01 2016-03-18 B 1250 3.53 2016-03-18 B 1500 1.56 2016-03-18 A 1500 8.24 2016-03-18 A 1750 2.19 2016-03-19 A 1000 4.21 2016-03-19 B 1000 1.98 2016-03-19 B 1250 3.48 2016-03-19 B 1500 1.79 2016-03-19 A 1500 8.50 I need the SQL query to combine rows that have the same value in Column3 for a given date (first column). In the source table there should be one row with "A" in Column2 and one row with "B" in Column2 for every instance of the date and the value in Column3. If there isn't a corresponding row for either "A" or "B" in the source table (I included a few examples above), I would like the AValue or BValue in the result set to be null if there isn't a row. Here's what the result set should look like: Date Column3 AValue BValue 2016-03-18 1000 5.43 2.01 2016-03-18 1250 null 3.53 2016-03-18 1500 8.24 1.56 2016-03-18 1750 2.19 null 2016-03-19 1000 4.21 1.98 2016-03-19 1250 null 3.48 2016-03-19 1500 8.50 1.79 I'm using MS SQL Server 2012, so the resulting query should be compatible with that database engine. I would prefer not to use a stored procedure or any code, hopefully this can all be done in straight SQL by someone much more knowledgeable than me. :-)
Ταυτότητα εργασίας: 10023449

Σχετικά με την εργασία

8 προτάσεις
Απομακρυσμένη Εργασία
Ενεργός/ή 8 χρόνια πριν

Ψάχνεις τρόπο για να κερδίσεις μερικά χρήματα;

Πλεονεκτήματα πλειοδοσίας στο Freelancer

Καθόρισε τον προϋπολογισμό σου και το χρονοδιάγραμμα
Πληρώσου για τη δουλειά σου
Περίγραψε την πρόταση σου
Η εγγραφή και η πλειοδοσία σε εργασίες είναι δωρεάν
Βραβεύτηκε στον/στην:
Avatar Χρήστη
Hi there, I would love to help you with your SQL. Here's my proposed solution using a full outer join. select case when [login to view URL] is null then [login to view URL] else [login to view URL] end as Dt ,case when [login to view URL] is null then [login to view URL] else [login to view URL] end as Col2 ,[login to view URL] as ValueA ,[login to view URL] as ValueB from (select * from ##test where Col1 = 'A') as a full outer join (select * from ##test where Col1 = 'B') as b on [login to view URL] = [login to view URL] and [login to view URL] = [login to view URL] Hope this helps. Marcelo
$12 USD σε 0 ημέρα
5,0 (3 αξιολογήσεις)
2,0
2,0
8 freelancers δίνουν μια μέση προσφορά $24 USD για αυτή τη δουλειά
Avatar Χρήστη
I will give you the query ........................................................................................................
$25 USD σε 1 ημέρα
5,0 (21 αξιολογήσεις)
6,1
6,1
Avatar Χρήστη
Hello, I have profissional experience of SQL. Could you please provide me the name of the table and the columns in order to construct the query with the correct fields. Thank you, Best regards, David
$15 USD σε 2 ημέρες
5,0 (17 αξιολογήσεις)
4,0
4,0
Avatar Χρήστη
I am an experienced database administrator and SQL developer. I can handle your requirement and provide you the right SQL statement
$25 USD σε 1 ημέρα
5,0 (8 αξιολογήσεις)
3,2
3,2
Avatar Χρήστη
I have knowledge and experience of writing complex SQL queries as part of my Job. I have done data warehousing testing which mainly revolves around complex SQL queries.
$20 USD σε 1 ημέρα
0,0 (0 αξιολογήσεις)
0,0
0,0
Avatar Χρήστη
I can do it. Hire me and I shall generate the query that you need in minutes. Just send me the tables and how you want the arrangement of the fields
$25 USD σε 1 ημέρα
0,0 (0 αξιολογήσεις)
0,0
0,0

Σχετικά με τον πελάτη

Σημαία της UNITED STATES
Cedar Park, United States
5,0
6
Επαληθευμένη μέθοδος πληρωμής
Μέλος από Μαρ 9, 2007

Επαλήθευση Πελάτη

Ευχαριστούμε! Σου έχουμε στείλει ένα email με ένα σύνδεσμο για να διεκδικήσεις τη δωρεάν πίστωση σου.
Κάτι πήγε στραβά κατά την προσπάθεια αποστολής του email σου. Παρακαλούμε δοκίμασε ξανά.
Εγγεγραμμένοι Χρήστες Συνολικές Αναρτημένες Δουλειές
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Φόρτωση προεπισκόπησης
Δόθηκε πρόσβαση για Geolocation.
Η σύνδεση σου έχει λήξει και τώρα έχεις αποσυνδεθεί. Παρακαλούμε συνδέσου ξανά.