Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mohask
Starting Member
2 Posts |
Posted - 2011-05-12 : 07:50:43
|
| Hi,Please go through the following SQL statements. I would require guidance for the last SQL statement. I want this query to return 780 and not 0.---------------------------------------------------------------------------------------------------SELECT COUNT(*) FROM Table1 WHERE VendorName = 'XXXXX'Returns 800SELECT COUNT(*) FROM Table1 WHERE UpdateSessionGUID='3E710C91-C678-430D-880C-C8CBE9881104' AND VendorName='XXXXX'Returns 20SELECT COUNT(*) FROM Table1 WHERE UpdateSessionGUID<>'3E710C91-C678-430D-880C-C8CBE9881104' AND VendorName='XXXXX'Returns 0---------------------------------------------------------------------------------------------------My concern is I want to return the total number of records that has the vendor name as 'XXXXX' and doesn't have UpdateSessionGUID as '3E710C91-C678-430D-880C-C8CBE9881104' (in this case it should return 780 where as it return 0)Your reply will be highly appreciated.Thank you. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-12 : 08:04:32
|
[code]WHERE (UpdateSessionGUID<>'3E710C91-C678-430D-880C-C8CBE9881104' or UpdateSessionGUID is null) AND VendorName='XXXXX'[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mohask
Starting Member
2 Posts |
Posted - 2011-05-12 : 08:07:51
|
quote: Originally posted by khtan
WHERE (UpdateSessionGUID<>'3E710C91-C678-430D-880C-C8CBE9881104' or UpdateSessionGUID is null) AND VendorName='XXXXX'
Already tried your advise and failed !! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-12 : 08:34:42
|
what do you mean exactly by "failed" ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|