Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get data from 2 tables
Message
 
 
À
07/02/2019 02:51:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008 R2
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01666006
Message ID:
01666013
Vues:
47
You should use WHERE Date IN (...) instead.

>Sir, I am using these codes with sqlserver 2008.
>
>I am trying to get data from two tables like this
>
>
>SELECT Date, DatePart(hour,Date) as Hr, reading
>FROM TABLE1 A
>WHERE Date = 
>
>(SELECT Min(Date) as date
> FROM TABLE1 B
> WHERE DatePart(hour,A.Date)= DatePart(hour,B.Date) 
>
> union all
>
> SELECT Min(Date)as date
> FROM TABLE2 C
> WHERE DatePart(hour,A.Date)= DatePart(hour,C.Date)) 
>
>
>but I am facing this error message
>
>
>Msg 512, Level 16, State 1, Line 1
>Subquery returned more than 1 value. This is not permitted when the subquery follows or when the subquery is used as an expression.
>
>How to overcome this?
>
>
>But this query work fine
>
>
>SELECT Date, DatePart(hour,Date) as Hr, reading
>FROM TABLE1 A
>WHERE Date = 
>
>(SELECT Min(Date) as date
> FROM TABLE1 B
> WHERE DatePart(hour,A.Date)= DatePart(hour,B.Date) ) 
>
>
>
>
>
>
>Please
Christian Isberner
Software Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform