.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

how to find the output in sqlserver

Posted By: Santosh     Posted Date: January 07, 2014    Points:5   Category :Sql Server
Hi
I have two tables mentioned below.i need to to merge these two tables and get the required output

Table 1

Name Upload
Rakesh 500
Mahesh 740
Rahul 0
Sanjay 600

Table 2

Name Download
Rakesh 200
Sanjay 120
Sambit 290


Output: from the above two tables

Name Uploads Download
Rakesh 500 200
Mahesh 740 0
Rahul 0 0
Sanjay 600 120
Sambit 0 290

Note:These Name are coming from user table.

Thanks
Santosh



Responses
Author: Akhil Raj       [Moderator]      
Posted Date: January 08, 2014     Points: 20   

You can use union to accmplish this

SELECT
Name,
SUM(Uploads) Uploads,
SUM(Download) Download,
FROM
(
select
Name,
Uploads,
0 as Download
from Table1

union all

select
Name,
0 as Uploads,
Download
from Table2
)
GROUP BY Name


Author: johngates             
Posted Date: February 21, 2014     Points: 20   

you can use it for getting your result

select
Name,
Uploads,
0 as Download
from Table1

union all

select
Name,
0 as Uploads,
Download
from Table2
)

for more http://apptuck.com/ latest technology news click over the link

Author: johngates             
Posted Date: March 19, 2014     Points: 20   

use this algo

mysql -u username -ppassword -h host_ip -P port_no --verbose < sql file on windows

or u can use

MyShell>mysql -u root -p --verbose test < "C:\Users\Ravinder\Desktop\mysql_stmt.sql"
Enter password: *****
--------------
select row_count()
--------------

row_count()
-1
--------------
create table y( x int )
--------------

--------------
select concat('table y ', if(row_count()=0, '', 'not '), 'created' ) 'result'
--------------

result
table y created

MyShell>



For more visit cqlsys.com



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend