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 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2011-06-22 : 15:59:44
|
| Count(Cos) from t16pendallwhere mft_posn1_cd=B or D) or mft_pos1_cd=A and aged_alien_rsw=yand cos not in t16pendmvt tableCount cos from T16pendmvt tablewhere mvt_typ=R and mvt_loc not like 'R, S, VCount Cos from T16pendmvt table where mvt_typ='t'How could I write them all together as a subquery? |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-06-22 : 23:32:59
|
| People cannot read your mind, so post your code and clear specs if you really want help. Please post real DDL and not narrative or your own personal programming language. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. Please tell us what SQL product and release you are using. Tell us if you can change the DDL or if you are stuck with it. The code you posted is not even close to SQL. Try again--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-06-29 : 04:17:16
|
| Something like thissum(case when (mft_posn1_cd in (B,D) or mft_pos1_cd=A and aged_alien_rsw=y then 1 else 0 end) as col1,sum(case when mvt_typ=R and mvt_loc not in ('R', 'S', 'V') then 1 else 0 end) as col2,etcMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|