How to combine two columns into one in an sql

I have an stored procedure that returns 3 columns. Month, Date, and Total Number of Calls.

Here is the stored Proc:

SELECT DATEPART(mm, CALLSTARTTIME) ,  DATEPART(dd, CALLSTARTTIME), COUNT(*)

FROM CALL_LOG_MASTER

WHERE (COMMERCIALS = '1') AND (PINCODE IS NOT NULL)

GROUP BY DATEPART(mm, CALLSTARTTIME), DATEPART(dd, CALLSTARTTIME)

ORDER BY DATEPART(mm, CALLSTARTTIME), DATEPART(dd, CALLSTARTTIME)

It returns a table:

MONTH   DATE   TOTAL NUMBER OF CALLS
=======   =====   ===========
1                  1               10

1                  2               15

My question is: is it possible to combine the Month and Date column into one column. e.g.

Date   Total Number of Calls
====   ==============
1/1      10
1/2      15

Please Help, Thanks in advance :)

0
daydream
12/7/2005 7:38:38 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

2 Replies
590 Views

Similar Articles

[PageSpeed] 24

  

SELECT CONVERT(nvarchar(2),DATEPART(mm, CALLSTARTTIME)) + '/' + CONVERT(nvarchar(2),DATEPART(dd, CALLSTARTTIME)) AS [Date], COUNT(*)

FROM CALL_LOG_MASTER

WHERE (COMMERCIALS = '1') AND (PINCODE IS NOT NULL)

GROUP BY DATEPART(mm, CALLSTARTTIME)) + '/' + CONVERT(nvarchar(2),DATEPART(dd, CALLSTARTTIME))

ORDER BY DATEPART(mm, CALLSTARTTIME), DATEPART(dd, CALLSTARTTIME)


Starting with ASP.NET 2.0? Look at:
Programming Microsoft Web Forms
My Blog
0
douglas
12/7/2005 9:40:03 PM

thx, I did some configuration. works like a charm

SELECT CONVERT(nvarchar(2),DATEPART(mm, CALLSTARTTIME)) + '/' + CONVERT(nvarchar(2),DATEPART(dd, CALLSTARTTIME)) AS [Date], COUNT(*)

FROM CALL_LOG_MASTER

WHERE (COMMERCIALS = '1') AND (PINCODE IS NOT NULL)

GROUP BY DATEPART(mm, CALLSTARTTIME) ,DatePart(dd, Callstarttime), CONVERT(nvarchar(2),DATEPART(mm, CALLSTARTTIME)) + '/' + CONVERT(nvarchar(2),DATEPART(dd, CALLSTARTTIME))

ORDER BY DATEPART(mm, CALLSTARTTIME), DATEPART(dd, CALLSTARTTIME)

0
daydream
12/7/2005 9:54:11 PM
Reply:

Similar Artilces:

How to Combine two column in one table using SQL statement ?
Could you write the simple SQL statement from 'Combine two column in one table '? I try to use 'Union' which combine two column in two table . thx You can use the concatention operator (+): SELECT column1 + column2 AS myColumn FROM myTable TerriTerri MortonEngagement Manager, NeudesicHow to ask a question If the columns are numeric then "+" will sum the column values. If you do not desire this, you should use str() function Check the below statement, select ltrim(str(column1)) + ltrim(str(column2)) from mytable http://www.eral...

SQL query to one column od database into two columns
Hi,I have a empskill Table which has 3 Columns (1) EmpID (2) SkillTypeID and (3) CourseID.Now  SkillTypeID column has data 1 or 2 .......in here 1 means Primary Skill and 2 means Secondary Skill. CourseID will reflect the ID's of subjects like c#,SQL,etc I need a Query which will count the number of primary skilled and number of secondary skilled persons based on subject and will display as followsCOURSE ID      SKILL TYPE  21                        222  &n...

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

How to combine two SQL Datasource and put it in GridView?
Hi, I'm trying to combine two datasources together. The reason I have to combine them is because, one database is used by a software that I can't manipulate, the other database is exact one I created for an internal custom software. They both have different connectionstrings. I have the VB code below. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)Dim PCConnectionString As String = "Data Source=Source1;Initial Catalog=Center;Persist Security Info=True"Dim PCcon As SqlConnection = New SqlConnection(PCConnectionString)Dim TCConnectio...

how to combine two sql commands in one DeleteCommand
Is there any way to have the SqlDataSource DeleteCommand execute two sql commands. That is, something like: DeleteCommand="DELETE FROM [HRMFile] WHERE [id_file] = @original_id_file;DELETE FROM [HRMFileLap] WHERE [id_file] = @original_id_file"> If not, is there a simple example of how to connect a stored procedure to the datasource. (like a tutorial or article?) Thanks, and Happy New Year!!! Peter Kellnerhttp://73rdstreet.com and blogging athttp://PeterKellner.netMVP, ASP.NET The Sql Statement in your example, should do what you want, but I would suggest you use ...

combine two tables with different columns in sql sever
Hi, I have a requirement like.. One table has 12 columns for all month  with different year.  Lets say i need values from sep-2008 to Mar-2009. I need to select the values from sep-2008 to dec-2008 as a single table and jan-2009 to Mar-2009 values as a single table. Now i need to combine these two table as a single table. Please help how to combine two tables with different columns. Thanks, Prabha  The question is unclear (put samples of exact data structure, test data and desired output). I think you need to look at UNPIVOT operator in SQL Server 2005. Look at the H...

Combining Two Fields from a SQL DB into One Dropdown box
What I am trying to do is to concatenate 2 fields from a table into 1 dropdown box. It comes up with an error when it tries to do a Databind. lblDept.Text = ("ID") & " - " & ("Description") ddlDept.DataTextField = lblDept.Text ddlDept.DataSource = GetDept() ddlDept.DataBind() What am I missing? Thanks, Ralph Hi Ralph, You may modify the SELECT statement as: SELECT ID + ' - ' + Description AS FullDetail FROM ... Then, set the FullDetail as the DataTextField. Colt Thanks for info....it works wonde...

can anyone show me how to combine these two SQL queries into one
Hello- i have a fairly big SQL query that is used to display data into a datagrid. Each query grabs data from two seperate databases. Is there anyway to combine these queries into one so all the data appears in 1 datagrid and not 2. here is the 1st query: SQL = "SELECT sum(case when month(pb_report_shippers.shipper_date_time) = 1 then pb_report_shippers_lots.quantity else 0 end) as Jan ,sum(case when month(pb_report_shippers.shipper_date_time) = 2 then pb_report_shippers_lots.quantity else 0 end) as Feb ,sum(case when month(pb_report_shippers.shipper_date_time) = 3 then pb_rep...

Combine Two Different Columns into one column
Hi Guys,   I have twotables(Employee and Borrower). In Employee table have EMPID and Borrower table have BorrowerID. I want to comebine these two columns into one column as EMPID  in Employee table. Can  any one help? Thanks what is realtion between to tables ?   Use    Union Thanks for reply. Acutally Employee table EMPID, NAME Columns. in this Employee table had 12000 rows. Borrower table has BorrowerID,BType etc.. .Here Employee ID and BorrowerID both are same. This table has 16000 rows. Now my what i want to do is Come EMPID and BorrowerID and ...

How To Combine 2 SQL Query Results Into One In Order To Bind to a Gridview Datasource?
Hi, Scenario: In code behind (.cs), I have to perform two seperate sql queries. For the simplicity, First I need to select the CustomerName from TableA. then another query to select CustomerPhone from TableB. Note that there IS NO join between these two tables. How can I combine these two resullts so that I can bind it to a single gridview datasource? Any suggestion for a simple solution.. ? Do your tables have only one column?  Iterate through tableB and copy all rows to tableA...  http://support.microsoft.com/kb/305346 It could also be done at...

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

how to operate two table of two DSN in one SQL statment?
I want to operate two table of two DSN in one SQL statment, please help me. I don't think it is possible to answer this question unless you let us know which DBMS you're using ;-) Geert 'Darling' Van Damme strong wrote in message ... >I want to operate two table of two DSN in one SQL statment, >please help me. > > You won't be able to do this directly, each DSN would require a separate ODBC connection and a separate transaction object in PowerBuilder. Different DBMS's do, however, have features that will let you reach across homo...

Display multiple columns in Gridview from One Column of SQL table
Hi I have a table in sql with 2 columns and I want to display that in multiple columns in Gridview. SQL Table No.            Type 1               A1 1               B2 2              A2 2               B2 3        &...

Combine WATCOM SQL and TRANSACT SQL Syntax
The WATCOM and TRANSACT SQL syntax descriptions should appear together in the Help. There are features of both which are helpful, and it is less than productive to have to read two Help topics to read about one SQL topic. For example, the syntax for SELECT is presented in two places, and they aren't connected in the "See Also" list. Also, the Help - Index facility should always jump to the syntax description as the first choice when a keyword like SELECT is chosen, not some general tutorial or other topic. Breck Hmmm. We'll have to see about this one. Here is...

Web resources about - How to combine two columns into one in an sql - asp.net.sql-datasource

Combine (enterprise) - Wikipedia, the free encyclopedia
... VEB Kombinat Robotron , an electronics manufacturer, and IFA , a manufacturer of vehicles, both in East Germany , and the Erdenet copper combine ...

STUDY: Combine Email Marketing with Facebook Ads
A study in which a leading U.S. retailer targeted 565,000 email subscribers with both its regular emails and coordinated Facebook News Feed ads ...

Facebook, Google, Twitter, LinkedIn combine to launch WebScaleSQL
Facebook’s oft-stated mission, per Mark Zuckerberg , is to make the world more open and connected. The social network joined tech giants Google, ...

Video Merger FREE - Combine Multiple Videos into One Video on the App Store on iTunes
Get Video Merger FREE - Combine Multiple Videos into One Video on the App Store. See screenshots and ratings, and read customer reviews.

New Quantum Key System Combines Speed, Distance - Flickr - Photo Sharing!
Detection stage of the NIST prototype quantum key distribution (QKD) system: Incoming photons already have been sorted into one of two quantum ...

'Suitsy' Combines Comfort of a Onsie With Look of a Slept-In Suit - YouTube
The Suitsy is a one-piece suit with the shirt, jacket and trousers all attached, and it zips up the front with a shirt button placard covering ...

Educator combines experience, drive and passion to help school pupils succeed
Muna Saqir Al Matroushi started teaching at the age of 18 and since then has devoted her time, money and effort into helping children develop, ...

Mashup of the Day: Todrick Hall Combines ’90s Pop Hits & Disney Songs
Remember that time Montell Jordan flew around on a magic carpet with a genie who granted him any wish his heart desired, all the while singing ...

Don’t combine chaplains and welfare workers
Our primary school is undertaking a community “consultation” over the appointment of a school chaplain versus a secular student welfare worker. ...

Full moon and solar eclipse combine for 'tide of the century' in northern France
Towns on France's coast braced for their first giant tide of the millennium as the full moon and the week's solar eclipse combined to create ...

Resources last updated: 12/22/2015 12:24:33 AM