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

  • Home
  • SEARCH
  • 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 9158495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:15:36+00:00 2026-06-17T13:15:36+00:00

I have MyTbl like this Id type amount — —- —— 1 1 100

  • 0

I have MyTbl like this

Id  type    amount
--  ----    ------
1   1       100
2   1       200
3   2       300
4   2       400

Is it possible to write a query for sqlite in Android that returns this?

Amount1 Amount2
------- -------
300     700

I have written the following query but it is not ok:

select SUM(a.amount) as Amount1, SUM(b.amount) as Amount2 from MyTbl a inner join MyTbl b
on a.id = b.id
group by a.type

it returns:

Amount1 Amount2
------- -------
300     300
700     700
  • 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-17T13:15:37+00:00Added an answer on June 17, 2026 at 1:15 pm
    SELECT
        SUM(CASE WHEN type = 1 THEN amount ELSE 0 END) amount1,
        SUM(CASE WHEN type = 2 THEN amount ELSE 0 END) amount2
    FROM MyTbl
    

    SQL FIDDLE

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

Sidebar

Related Questions

Let's say I have this table MyTbl Record Id_try Id Type IsOk DateOk 1
i have field Tdate (text type) on my Table MyTbl i need query that
i have this code for fill combo-box SQL = SELECT DISTINCT Name,Num FROM MyTbl
I have the following JavaScript code. var myCellCollection = document.getElementById('myTbl').cells; This works well in
I have used this type of functionality before but is MSSQL but can't get
I have a table like this. +-------------+-------+-------+-------+-------+-------+ | studentCode | term1 | term2 |
I know this might be redundant but I have had the same query running
I have this table: <table class=mytbl> <thead> <tr> <th>dyn-tbl-hdr-1</th> <----these actually are timestamps. <th>dyn-tbl-hdr-2</th>
I have this query below but I'm afraid it will not work when the
I have a table defined like this: CREATE TABLE mytable (id INT NOT NULL

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.