Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select first rows from subselect
Message
De
05/10/2015 20:46:42
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Réplication
Titre:
Select first rows from subselect
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01625508
Message ID:
01625508
Vues:
78
Good night, please help me with the following: I need to bring the first row from a table that have a lot of records but filtering for a specific column that is in other table:
models:
code     name       idcompany
001       BLUE          10
002       RED            20
003       BLACK        10
004       WHITE        99

data:
date           hour        model        temperature       energy
01/01/15      17:55    001                 4.5                  1
01/01/15      18:00    002                 5.5                  1
01/01/15      18:05    003                 6.3                  1
01/01/15      19:01    001                 6.5                  1
01/01/15      19:05    004                 5.5                  1
01/01/15      19:10    001                 4.5                  1
01/01/15      19:15    001                 4.5                  1
01/01/15      19:20    002                 5.5                  1
01/01/15      19:25    003                 6.3                  1
01/01/15      19:30    001                 6.5                  1
01/01/15      19:35    004                 5.5                  1
01/01/15      19:40    001                 4.5                  1


this is what I need:

results:
filtered by idcompany=10
code     name     date             hour          temp    energy
001       BLUE    01/01/15      19:40          4.5         1
003       BLACK  01/01/15      19:25          6.3         1
I need to bring the last record in data for the idcompany=10. I need this without using cursor or temporary table, would be possible with just one query?

TIA.
John Harold Belalcázar Lozano
Associate Director Of Development
http://www.belvicto.co/
jhbelalc@gmail.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform