Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:02:27+00:00 2026-06-17T21:02:27+00:00

i have the following table: CREATE TABLE ta91 ( id INTEGER NOT NULL PRIMARY

  • 0

i have the following table:

    CREATE TABLE ta91 (
    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 
    date INTEGER, 
    _520  INTEGER, 
    _530 INTEGER,
    _540 INTEGER,
    _550 INTEGER,
    _560 INTEGER,
    _570 INTEGER,
    _580 INTEGER,
    _590 INTEGER,
    _600 INTEGER,
    _610 INTEGER,
    _620 INTEGER,
    _630 INTEGER,
    _640 INTEGER,
    _650 INTEGER,
    _660 INTEGER,
    _670 INTEGER,
    _680 INTEGER,
    _690 INTEGER,
    _700 INTEGER,
    _710 INTEGER,
    _720 INTEGER,
    _730 INTEGER,
    _740 INTEGER,
    _750 INTEGER,
    _760 INTEGER,
    _770 INTEGER,
    _780 INTEGER,
    _790 INTEGER,
    _800 INTEGER,
    _810 INTEGER,
    _820 INTEGER,
    _830 INTEGER,
    _840 INTEGER,
    _850 INTEGER
)

with the values:

INSERT INTO "someTable" VALUES ("10","1355480306018","1","0","0","0","0","1","0","0","0","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0");
INSERT INTO "someTable" VALUES ("11","1355480307044","1","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","0");
INSERT INTO "someTable" VALUES ("12","1355480308027","1","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","0");
INSERT INTO "someTable" VALUES ("13","1355480309033","1","0","0","0","0","1","0","0","0","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0");
INSERT INTO "someTable" VALUES ("14","1355480310038","1","0","0","0","0","1","0","0","0","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0");
INSERT INTO "someTable" VALUES ("15","1355480311043","1","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","0");
INSERT INTO "someTable" VALUES ("16","1355480312043","1","0","0","0","0","0","0","0","1","0","0","0","1","0","0","0","0","0","1","1","1","1","0","0","0","0","0","0","0","0","0","0","0","0");
INSERT INTO "someTable" VALUES ("17","1355480313048","1","0","0","0","0","1","0","0","0","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0");

how can i count the number of times the value switches from 0/1 resp. 1/0 for each column directly in sql?

i am using c# with System.Data.SQLite.dll 1.0.82.0 to access the database

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:02:28+00:00Added an answer on June 17, 2026 at 9:02 pm

    Assuming

    1. no portability requirements outside of sqlite;
    2. consecutive id values;
    3. the need to count (for each column) total number of times for both 0-to-1 and 1-to-0 switches;
    4. table name being someTable, like in your INSERT statements;

    You can use this:

    SELECT SUM(a._520<>b._520) AS s_520,
           SUM(a._530<>b._530) AS s_530,
           SUM(a._540<>b._540) AS s_540,
           SUM(a._550<>b._550) AS s_550,
           SUM(a._560<>b._560) AS s_560,
           SUM(a._570<>b._570) AS s_570,
           SUM(a._580<>b._580) AS s_580,
           SUM(a._590<>b._590) AS s_590,
           SUM(a._600<>b._600) AS s_600,
           SUM(a._610<>b._610) AS s_610,
           SUM(a._620<>b._620) AS s_620,
           SUM(a._630<>b._630) AS s_630,
           SUM(a._640<>b._640) AS s_640,
           SUM(a._650<>b._650) AS s_650,
           SUM(a._660<>b._660) AS s_660,
           SUM(a._670<>b._670) AS s_670,
           SUM(a._680<>b._680) AS s_680,
           SUM(a._690<>b._690) AS s_690,
           SUM(a._700<>b._700) AS s_700,
           SUM(a._710<>b._710) AS s_710,
           SUM(a._720<>b._720) AS s_720,
           SUM(a._730<>b._730) AS s_730,
           SUM(a._740<>b._740) AS s_740,
           SUM(a._750<>b._750) AS s_750,
           SUM(a._760<>b._760) AS s_760,
           SUM(a._770<>b._770) AS s_770,
           SUM(a._780<>b._780) AS s_780,
           SUM(a._790<>b._790) AS s_790,
           SUM(a._800<>b._800) AS s_800,
           SUM(a._810<>b._810) AS s_810,
           SUM(a._820<>b._820) AS s_820,
           SUM(a._830<>b._830) AS s_830,
           SUM(a._840<>b._840) AS s_840,
           SUM(a._850<>b._850) AS s_850
    FROM "someTable" a INNER JOIN "someTable" b
    ON a.id = b.id-1;
    

    Of course, I’ve generated this thing. So could you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table: CREATE TABLE posting ( id integer NOT NULL PRIMARY
I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER,
I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER
When I have the following table: CREATE TABLE test ( id integer NOT NULL,
I have the following table: CREATE TABLE notes (noteId INTEGER PRIMARY KEY ASC, note,
I have the following table: CREATE TABLE [dbo].[Data] ( [Id] UNIQUEIDENTIFIER NOT NULL, [Data]
I have the following table: CREATE TABLE [dbo].[Tree]( [AutoID] [int] IDENTITY(1,1) NOT NULL, [Category]
I have the following table structures CREATE TABLE [dbo].[WorkItem]( [WorkItemId] [int] IDENTITY(1,1) NOT NULL,
I have following table and data: create table Foo ( id int not null,
We have the following table: CREATE TABLE [dbo].[CampaignCustomer]( [ID] [int] IDENTITY(1,1) NOT NULL, [CampaignID]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.