Problemi nella selezione di dati da una tabella

lunedì 26 gennaio 2009 - 10.56

paovanm Profilo | Junior Member

Ho questa situazione, qualcuno può aiutarmi?

NOMI COLONNE TABELLA APPARTENENZA
Numerodemotor AAA_TestTable
TAG_i_NumberTestBench AAA_TestTable
TAG_q_PalletNumber AAA_TestTable
TAG_TestDateTime AAA_TestTable
[Value] [MEA_EngSpeedMI]
[Min] [MEA_EngSpeedMI]
[Max] [MEA_EngSpeedMI]
[Judgment] [MEA_EngSpeedMI]
Occurrence [MEA_EngSpeedMI]

SELECT Numerodemotor, TAG_i_NumberTestBench, TAG_q_PalletNumber, TAG_TestDateTime,[Value],[Min],[Max],[Judgment],Occurrence
FROM AAA_TestTable AS V1, [MEA_EngSpeedMI] AS V2
WHERE (V1.KeyTesT = V2.KeyTesT)
AND (V2.Position=1 AND V2.Step=3)
AND (V1.KeyTest ='01_20/07/2008_14:38:11' OR V1.KeyTest ='04_12/02/2007_09:31:44' OR V1.KeyTest ='04_14/10/2008_18:44:39' OR V1.KeyTest ='04_14/10/2008_19:34:29' OR V1.KeyTest ='04_14/10/2008_19:51:15' OR V1.KeyTest ='04_14/10/2008_20:27:58' OR V1.KeyTest ='04_14/10/2008_20:45:20' OR V1.KeyTest ='04_14/10/2008_21:12:00' OR V1.KeyTest ='04_14/10/2008_21:26:39' OR V1.KeyTest)
ORDER BY Numerodemotor,Occurrence DESC

Esempio risultato della query precedente(l’ordine delle collonne è quello della query):

600083-B 1 4 2008-07-20 14:38:11.000 751 650 850 1 1
614030-B 10 31 2008-10-15 06:57:50.000 759 650 850 1 1
614034-B 4 77 2008-10-15 07:05:05.000 752 650 850 1 1
614047-B 5 14 2008-10-15 07:05:16.000 750 650 850 1 2
614047-B 5 14 2008-10-15 07:05:16.000 753 650 850 1 1
614889-B 10 26 2008-10-14 18:47:34.000 751 650 850 1 2
614889-B 10 26 2008-10-14 18:47:34.000 758 650 850 1 1
614892-B 8 19 2008-10-14 19:27:23.000 750 650 850 1 1
614895-B 7 21 2008-10-14 19:03:36.000 758 650 850 1 1
614896-B 4 77 2008-10-14 18:44:39.000 753 650 850 1 1
614966-B 9 22 2008-10-15 06:15:25.000 767 650 850 1 3
614966-B 9 22 2008-10-15 06:15:25.000 769 650 850 1 2
614966-B 9 22 2008-10-15 06:15:25.000 761 650 850 1 1


Come faccio ad ottenere solo le righe con ‘Occurrence’ maggiore a parità di ‘Numerodemotor’?
Per esempio il risultato che vorrei io è:

600083-B 1 4 2008-07-20 14:38:11.000 751 650 850 1 1
614030-B 10 31 2008-10-15 06:57:50.000 759 650 850 1 1
614034-B 4 77 2008-10-15 07:05:05.000 752 650 850 1 1
614047-B 5 14 2008-10-15 07:05:16.000 750 650 850 1 2
614889-B 10 26 2008-10-14 18:47:34.000 751 650 850 1 2
614892-B 8 19 2008-10-14 19:27:23.000 750 650 850 1 1
614895-B 7 21 2008-10-14 19:03:36.000 758 650 850 1 1
614896-B 4 77 2008-10-14 18:44:39.000 753 650 850 1 1
614966-B 9 22 2008-10-15 06:15:25.000 767 650 850 1 3

Grazie in anticipo
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5