Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get data from 2 tables
Message
From
07/02/2019 03:40:43
 
 
To
07/02/2019 02:51:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008 R2
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01666006
Message ID:
01666009
Views:
51
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform