You need to change the datatype to varchar(10) to get the dates as it is in the excel sheet. Then you need to convert it into datetime format so that it has the right month and day.
To create a temp table with the same structure as original table do the following:
1. In SQL query analyser...
select day(datecolumn) as day,
cast(min(ticketno) as varchar(5)) + ' (to) ' +
cast(max(ticketno) as varchar(5)) as ticketnumber, sum(Amount) as TotalAmount
from Table
where month(datecolumn) = 8 /*for august*/
group by day(datecolumn)
order by day(datecolumn)
-Manjari
Hi EO,
Create a temporary table with exactly the same datatype for all other columns in the original table excpet for date coulmn. For date column change the datatype to
varchar(10). Then import the spreadsheet saved under US format into this temporary table.
Then copy the records from...
I am not very familiar with SQL Server 6.5 syntax
Try this:
Declare @MaxCnt int
select @MaxCnt = max(x.Cnt)
from (select membership_no, count(distinct role_no) as Cnt from #Role group by membership_no) x
select A.membership_no, A.First_Name, A.SurName, @MaxCnt as RoleCnt
from #Member A join...
select A.membership_no, A.First_Name, A.SurName, B.Cnt as RoleCnt
from #Member A join
(
select top 1 membership_no,count(distinct role_no) as Cnt from #Role group by membership_no order by Cnt desc
) B
on A.membership_no = B.membership_no
-Manjari
select * from BOLS a
where not exists (select distinct b.BOLNUM, b.ORDERNUM,b.INVNUM from BOLS b join BOLINOB c on b.BOLNUM = c.BOLNUM and b.ORDERNUM = c.ORDERNUM
and b.INVNUM = c.INVNUM and b.BOLNUM = a.BOLNUM and b.ORDERNUM = a.ORDERNUM and b.INVNUM = a.INVNUM)
-Manjari
Is it possible that the table tbl_JobItems is present under two different users in the same database? (i.e., one with your login.Table and ApplicationLogin.Table)??
Try this, Its not clear from your query if year will be same always. If it is same, then just take the difference of month values. Else convert day,month,year into a datetime and get the difference of min, max dates grouped by posgid, upby.
For the user Gerar, if you want 0 months as result...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.