Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get data from 2 tables
Message
De
07/02/2019 03:40:43
 
 
À
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:
01666009
Vues:
52
You tell us what does not work, and want us to try to understand what your code tries to do. That's not a very helpful...! Instead you should tell us what exactly you want, and add the details necessary.

And you should also provide some sample data, so that we can test what we suggest for you. See my signature for help on providing sample data.

>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform