Forum: MS SQL 17 Days Ago |
| Replies: 6 Views: 565 I think there are some (ClientID = 1126) in table Receipts.
Change your SQL to:
SELECT Clients.ClientID, Clients.WholeName,
SUM(CASE WHEN Payments.Creditorid = 0 THEN Payments.Amount ELSE... |
Forum: MS SQL 18 Days Ago |
| Replies: 6 Views: 565 I think there are data double in table Receipts.
Please give some data for example. |
Forum: MS SQL 23 Days Ago |
| Replies: 4 Views: 542 Try code below
set nocount on
CREATE TABLE #tmpName (ID int, [Name] varchar(255))
CREATE TABLE #tmpRelation (ID int, ID_Parent int)
INSERT #tmpName (ID, [Name]) select 1, 'value1'
INSERT... |
Forum: MS SQL 25 Days Ago |
| Replies: 4 Views: 542 Can u give some data and the result you want?
or you can see http://www.daniweb.com/forums/thread114466.html. |
Forum: MS SQL Jul 29th, 2009 |
| Replies: 2 Views: 684 maybe you can use CASE ... WHEN ... END command like below:
select cast(case when exists (SELECT * FROM UserList WHERE UserName = 'Tester') then 1 else 0 end as bit) |
Forum: MS SQL Dec 27th, 2008 |
| Replies: 3 Views: 1,104 Make it subquery like below:
select [Year], [Month], sum([Benefits Rating]) as [Benefits Rating], sum([Facilities Rating]) as [Facilities Rating]
from (...... your origin query ......) X
... |
Forum: MS SQL Nov 24th, 2008 |
| Replies: 3 Views: 882 Try this command:
select T1.idx, T2.idy, T2.u
from Table1 T1 right join Table2 T2 on
T1.idy = T2.Idy and T1.idx = 'one' |
Forum: MS SQL Nov 19th, 2008 |
| Replies: 4 Views: 629 change your command into:
select *
from (Select table_name
from information_schema.tables
where table_name= @table_name
) AliasName
change your... |
Forum: MS SQL Nov 15th, 2008 |
| Replies: 5 Views: 1,477 Use this command
select sum(Total) as [Amount]
from
(
select T1.Amount+T2.Amount as Total From TABLE1 T1 INNER TABLE2 T2 ON T1.ID = T2.ID
union all
select Amount as Total... |
Forum: MS SQL Nov 13th, 2008 |
| Replies: 5 Views: 1,477 select sum(Total)
from
(
select T1.Amount+T2.Amount as Total From TABLE1 T1 INNER TABLE2 T2 ON T1.ID = T2.ID
union all
select Amount as Total FROM TABLE3
) X |
Forum: MS SQL Sep 6th, 2008 |
| Replies: 8 Views: 2,569 Try this one:
select completed
from table
order by case when completed is null then 0 else 1 end, completed desc |
Forum: MS SQL May 12th, 2008 |
| Replies: 6 Views: 1,453 Try this code
select c.name, isNull(doc_A.Doc_A, 0) as Doc_A, isNull(doc_B.Doc_B, 0) as Doc_B, isNull(doc_C.Doc_C, 0) as Doc_C, isNull(doc_D.Doc_D, 0) as Doc_D
from tUsers u inner join... |
Forum: MS SQL May 9th, 2008 |
| Replies: 2 Views: 5,879 You cannot increase this limit. You must change your program. See http://www.daniweb.com/forums/thread114466.html. Hope this link can give you some idea. |
Forum: MS SQL Apr 23rd, 2008 |
| Replies: 2 Views: 7,987 update ABC
set XYZ = left(XYZ, 8) + 'A' + substring(XYZ, 9, 1000)
where XYZ like '%P' and XYZ not like '%A%' |
Forum: MS SQL Apr 10th, 2008 |
| Replies: 2 Views: 1,236 The correct code is:
select * from mail3 where email like '%+%' or email like '%*%' |
Forum: MS SQL Apr 2nd, 2008 |
| Replies: 2 Views: 2,831 Hope this code can help you.
1. Execute your first SP in query analyzer to show the columns list.
2. Create temporary table and the field must the same as first SP columns
create table... |