union

Count email type per customer id

烂漫一生 提交于 2019-12-24 02:09:44
问题 I have a form that people can use to send emails to our clients. The user has an option to select between two canned messages (Message "1" or Message "2"). Behind the scenes, every time they hit the "SEND" button it logs into a "RECORDS" table (so long as it makes it through the error handlers). Let's pretend the RECORDS table has 2 columns: CUST_ID EMAIL_NUM 0000 1 0000 2 0000 1 0000 1 0001 2 0002 1 0002 1 0003 2 0003 2 0003 2 I need a query that counts the ones and twos for each CUST_ID. So

error: expression is not assignable ternary operator

谁都会走 提交于 2019-12-23 21:12:04
问题 I have the following code and MPLABX XC8 compiler gives this error: error: expression is not assignable U1ERRIRbits.RXFOIF ? uart1.oerr = 1 : uart1.oerr = 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ Here is the relevant code section: typedef union { struct { bool ferr : 1; // FERIF Framing Error bool aerr : 1; // ABDOVF Error bool oerr : 1; // RXFOIF Error bool ready : 1; // Data Ready to be read uint8_t reserved : 4; }; uint8_t status; }uart1_status_t; static volatile uart1_status

mysql select count union

大憨熊 提交于 2019-12-23 21:05:54
问题 I have something like this: (SELECT COUNT(*) AS total FROM `transactions` WHERE `asset`='u_{$user_id}' GROUP BY id) UNION DISTINCT (SELECT COUNT(*) AS total FROM transactions tr INNER JOIN payments pa ON tr.asset = CONCAT('p_', pa.id) WHERE pa.user_id = '{$user_id}' GROUP BY tr.id) It gives 1 Now works like this: SELECT (SELECT COUNT(*) FROM `transactions` WHERE `asset`='u_{$user_id}') + (SELECT COUNT(*) FROM transactions tr INNER JOIN payments pa ON tr.asset = CONCAT('p_', pa.id) WHERE pa

Using SELECT UNION and returning output of two columns from one table

允我心安 提交于 2019-12-23 20:05:20
问题 I am creating a query that counts the amount of male and female actors in my table. My current statement is as such: Select COUNT(ActorGender) “Male Actors” from (tblActor ta WHERE ta.ActorGender in(‘m’) UNION Select COUNT(ActorGender) “Female Actors” from tblActor ta WHERE ta.ActorGender in(‘f’); The output ends up being: Male Actors ----------- 7 21 I want the output to look like: Male Actors Female Actors ----------- ------------- 7 21 I am looking for an alternative to go about this

Union-ing two custom classes returns duplicates

笑着哭i 提交于 2019-12-23 19:54:25
问题 I have two custom classes, ChangeRequest and ChangeRequests , where a ChangeRequests can contain many ChangeRequest instances. public class ChangeRequests : IXmlSerializable, ICloneable, IEnumerable<ChangeRequest>, IEquatable<ChangeRequests> { ... } public class ChangeRequest : ICloneable, IXmlSerializable, IEquatable<ChangeRequest> { ... } I am trying to do a union of two ChangeRequests instances. However, duplicates do not seem to be removed. My MSTest unit test is as follows: var cr1 = new

Union in c# with StructLayout

人走茶凉 提交于 2019-12-23 19:45:50
问题 I have multiple structs that all starts with a header struct. Like this public struct BaseProtocol { public Header header; public Footer footer; }; The header is public struct Header { public Byte start; public Byte group; public Byte dest; public Byte source; public Byte code; public Byte status; }; The problem now is that I need to union them with a Byte[]. I tried it with this [StructLayout( LayoutKind.Explicit, Size=255 )] public struct RecBuffer { [FieldOffset( 0 )] public Header header;

How can I combine SQL queries with different expressions?

不问归期 提交于 2019-12-23 19:28:47
问题 I've got three queries that are already at the peak of my SQL knowledge (Microsoft SQL 2005, if that matters) - and now I need to combine them into a single query with all of the values on a single row. My actual queries are below, but I thought it'd be easier if I provided a simple version here: Query One: -- Provides School District summary based on a CountyID SELECT DistrictID, Count(Schools) as NumberofSchools FROM Schools WHERE (CountyID = 207) GROUP BY DistrictID Query One Sample Output

What is phpMyAdmin doing to my UNION ALL query?

£可爱£侵袭症+ 提交于 2019-12-23 12:14:17
问题 The following query returns 1 row: SELECT `coach_id` FROM `table_a` WHERE `coach_id` = 8 UNION ALL SELECT `coach_id` FROM `table_b` WHERE `coach_id` = 8 But SELECT coach_id FROM table_b WHERE coach_id = 8 returns 2 rows. And SELECT coach_id FROM table_a WHERE coach_id = 8 returns 1 row. I'm using UNION ALL to avoid the DISTINCT filtering, because I'm actually just interested in the total number of rows. Still it seems to behave like regular UNION a.k.a UNION DISTINCT . Whats going on here?

UNION ALL Performance IN SQL Server 2005

断了今生、忘了曾经 提交于 2019-12-23 12:00:19
问题 I have a query with a long chain of CTEs which ends with SELECT RegionName, AreaName, CityName, SubCityName, StreetName FROM tDictionaryStreets UNION ALL SELECT RegionName, AreaName, CityName, SubCityName, StreetName FROM tDictionaryRegions The execution time of this query is 1450 ms. When I execute these 2 SELECTs separatly it takes much less time. For the query SELECT RegionName, AreaName, CityName, SubCityName, StreetName FROM tDictionaryStreets execution time is 106 ms. And for the query

UNION causes “Conversion failed when converting the varchar value to int”

喜你入骨 提交于 2019-12-23 09:07:08
问题 I tried to search for previous articles related to this, but I can't find one specific to my situation. And because I'm brand new to StackOverflow, I can't post pictures so I'll try to describe it. I have two datasets. One is 34 rows, 1 column of all NULL s. The other 13 rows, 1 column of varchar s. When I try to UNION ALL these two together, i get the following error: Conversion failed when converting the varchar value to data type int. I don't understand why I'm getting this error. I've