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 8507433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:52:13+00:00 2026-06-11T02:52:13+00:00

I have these tables: doodhiya dhid INTEGER PRIMARY KEY NOT NULL, dname TEXT NOT

  • 0

I have these tables:

doodhiya

dhid INTEGER PRIMARY KEY NOT NULL, 
dname TEXT NOT NULL, 
dfname TEXT NOT NULL, 
dage INTEGER NOT NULL, 
dadd TEXT, 
dphone INTEGER NOT NULL, 
demail TEXT NOT NULL

doodhdata

dtid INTEGER PRIMARY KEY NOT NULL, 
ddate INTEGER NOT NULL, 
dmonth INTEGER NOT NULL,
dyear INTEGER NOT NULL, 
dmilk INTEGER NOT NULL, 
dprice INTEGER NOT NULL default 35 , 
dmore TEXT, 
ddhid INTEGER NOT NULL

pricemilk

pid INTEGER PRIMARY KEY NOT NULL, 
pmonth INTEGER NOT NULL, 
pyear INTEGER NOT NULL, 
milkprice INTEGER NOT NULL, 
typeperson TEXT, 
userid INTEGER, 
gheeprice INTEGER, 
defaultprice TEXT

cashdata

cashid INTEGER PRIMARY KEY NOT NULL,
cashdate INTEGER NOT NULL, 
cashmonth INTEGER NOT NULL, 
cashyear INTEGER NOT NULL, 
cashamount INTEGER NOT NULL, 
uid INTEGER NOT NULL, 
utype TEXT NOT NULL, 
cashtype TEXT NOT NULL, 
cashmore TEXT

I want to make a monthly bill and I am succeed buy using it… but in a bill how can i show last month balance….I am trying to use it

 SELECT
  ddhid, dmonth, dyear, dmilk,
  userid, pmonth, pyear, milkprice, 
  uid, cashmonth, cashyear, cashamount, utype, 
  SUM(dmilk) AS totalmilk,  
  SUM(dmilk*milkprice) AS totalamount, 
  SUM(cashamount) AS totalcash
  FROM 
 doodhdata 
 LEFT JOIN pricemilk ON (
   doodhdata.ddhid = pricemilk.userid 
   AND doodhdata.dmonth = pricemilk.pmonth 
   AND doodhdata.dyear = pricemilk.pyear
 )
 LEFT JOIN cashdata ON (
   doodhdata.ddhid = cashdata.uid 
   AND doodhdata.dmonth = cashdata.cashmonth 
   AND doodhdata.dyear = cashdata.cashyear
 )
 WHERE 
   dmonth > '$mikdatem' 
   AND dyear='$mikdatey' 
   AND ddhid='$dhid'

But I want to use defaultprice when milkprice is NULL….how it is possible…?

  • 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-11T02:52:15+00:00Added an answer on June 11, 2026 at 2:52 am

    Use

    COALESCE(milkprice, defaultprice)
    

    in place of milkprice in your query.

    See SQLite core functions documentation.

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

Sidebar

Related Questions

Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
I have these tables CREATE TABLE parent ( id NUMBER(10, 0) NOT NULL, name
Let's say we have these tables: CREATE TABLE A ( id SERIAL NOT NULL
I have these tables: create table Person ( PersonId int identity(1,1) primary key, PersonName
I have these tables: media id (int primary key) uri (varchar). media_to_people media_id (int
I have these tables: CREATE TABLE User( Username varchar(15) NOT NULL, Name varchar(20) DEFAULT
I have these tables; Customer - CustomerID (primary key) - Name Car - CarID
Suppose I have these tables create table bug ( id int primary key, name
I have these tables: CREATE TABLE [EDR_SECURITY].[Person]( [ixPerson] [bigint] IDENTITY(1,1) NOT NULL, [sName] [nvarchar](200)
I have these tables: Projects(projectID, CreatedByID) Employees(empID,depID) Departments(depID,OfficeID) Offices(officeID) CreatedByID is a foreign key

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.