Sql query to bind data from grid and print total count and amount total when date changes

SELECT SLHD.VOUCH_CODE,SLHD.VOUCH_DATE,SLHD.VOUCH_NUM,SUM(SLTXN.CALC_NET_AMT) AS AMT,ACT.ACT_NAME,SUM(SLTXN.TOT_QTY) AS QTY
FROM SL_HEAD20132014 AS SLHD,ACCOUNTS AS ACT,SL_TXN20132014 AS SLTXN
WHERE SLHD.ACT_CODE=ACT.ACT_CODE AND SLTXN.VOUCH_CODE=SLHD.VOUCH_CODE
GROUP BY SLHD.VOUCH_CODE,SLHD.VOUCH_DATE,SLHD.VOUCH_NUM,ACT.ACT_NAME
ORDER BY SLHD.VOUCH_DATE 
i want to print total quatity and total sale in grid when data changes
like
date amount quantity
01/02/2013 1200 1
01/02/2013  200 1
01/02/2013  1400 2 // date changes here 
02/03/2013 100 1 
02/03/2013 50 4
02/03/2013 150 5 // date changes and so on

this query only print all the data from table i want total quantity and total amount of daily sale in same grid when ever date changes
You may add the date filter to Visakh's query:
SELECT SLHD.VOUCH_DATE,SUM(SLTXN.CALC_NET_AMT) AS AMT,SUM(SLTXN.TOT_QTY) AS QTY
FROM SL_HEAD20132014 AS SLHD,ACCOUNTS AS ACT,SL_TXN20132014 AS SLTXN
WHERE SLHD.ACT_CODE=ACT.ACT_CODE AND SLTXN.VOUCH_CODE=SLHD.VOUCH_CODEand SLHD.VOUCH_DATE = @yourdate --passed from the front end application
GROUP BY SLHD.VOUCH_DATE
WITH CUBE
ORDER BY SLHD.VOUCH_DATE
Having said, each time when you select the date, you query the table would be expensive method. May be you can filter the date within your dataset already populated if you have entire data in the dataset.

Similar Messages

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • Selecting all data from employee where foreign key = null and show it in view

    Hi guys i have view like following :
    SELECT dbo.Nationality.NationalityName, dbo.Employee.DriverName, dbo.Employee.DriverID, dbo.Employee.NationalityID, dbo.Employee.ResidentNo,
    dbo.Country.CountryName, dbo.Employee.CountryID, dbo.Branch.BranchName, dbo.Employee.BranchID, dbo.Employee.JoinDate,
    dbo.Employee.ResignDate, dbo.Employee.HealthCarNo, dbo.Employee.JobID, dbo.Jobs.JobName, dbo.Department.DepartmentName,
    dbo.Jobs.DepartmentID, dbo.Employee.PlaceIssue, dbo.Employee.Deduction, dbo.Employee.ExpireDateMedical, dbo.Employee.PolicyNumber,
    dbo.Employee.Owner, dbo.Employee.Version, dbo.Employee.ExpireDateResident, dbo.Employee.Salary, dbo.Employee.SexID, dbo.Sex.SexType,
    dbo.Sex.FlagSex, dbo.Employee.MiritialID, dbo.Miritial.MiritualStatus, dbo.Status.StatusType, dbo.Employee.StatusID, dbo.Employee.UnactiveReason,
    dbo.Employee.BirthDate, dbo.Employee.DateToday, dbo.Employee.UserID, dbo.Employee.PassportNo, dbo.Employee.Period,
    dbo.Employee.AccountNo, dbo.Employee.Bonus, dbo.Employee.AccountType, dbo.Employee.PlaceOfBirth, dbo.Employee.EmplyeeName,
    dbo.Employee.ExpireDateresidentHijri, dbo.Employee.PassportDateStart, dbo.Employee.PassportDateExpire, dbo.Religon.ReligonName,
    dbo.Employee.ReligonID
    FROM dbo.Nationality INNER JOIN
    dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID INNER JOIN
    dbo.Country ON dbo.Employee.CountryID = dbo.Country.CountryID INNER JOIN
    dbo.Branch ON dbo.Employee.BranchID = dbo.Branch.BranchID INNER JOIN
    dbo.Jobs ON dbo.Employee.JobID = dbo.Jobs.JobID INNER JOIN
    dbo.Department ON dbo.Jobs.DepartmentID = dbo.Department.DepartmentID INNER JOIN
    dbo.Sex ON dbo.Employee.SexID = dbo.Sex.SexID INNER JOIN
    dbo.Miritial ON dbo.Employee.MiritialID = dbo.Miritial.MiritialID INNER JOIN
    dbo.Status ON dbo.Employee.StatusID = dbo.Status.StatusID INNER JOIN
    dbo.Religon ON dbo.Employee.ReligonID = dbo.Religon.ReligonID
    suppose i need to show all data from Employee table (NationalityName,BranchName,JobName) where
    NationalityID =NULL OR BranchID=NULL OR JobID=NULL
    WHAT I DO
    Notes : I mean in topic(selecting all data from view not table
    meaning i need to show all data in employee table by view
    in case of forign key(any forign key)equal null

    I think you need to change 
    FROM dbo.Nationality INNER JOIN
    dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID
    to
    FROM dbo.Nationality
    LEFT JOIN
    dbo.Employee ON dbo.Nationality.NationalityID = dbo.Employee.NationalityID
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Is it possible to take the CDR data from a v4.2 Call Manager and copy it to a separate server where it would be made available for reporting?

    Is it possible to take the CDR data from a v4.2 Call Manager and copy it to a separate server where it would be made available for reporting? We are not interested in migrating the CDR data to v6 because of the concerns it introduces to the upgrade process. Is it possible to get the raw data and somehow serve it from a different machine? (knowing it would be 'old' data that stops as of a certain date). If so, what would be the complexity involved in doing so?
    It seems like the CDR data lives within MSSQL and the reporting interface is within the web server portion of the Call Manager... that's as far as we've dug so far.

    Hi
    It is absolutely possible to get the data - anyone you have in your org with basic SQL skills can move the data off to a standalone SQL server. This could be done most simply by backing up and restoring the DB using SQL Enterprise Manager.
    Moving the CAR/ART reporting tool would be more difficult... if you do actually use that for reporting (most people find it doesn't do what they need and don't use it for anything but basic troubleshooting, and get a third party package) then the best option may be to keep your publisher (possibly assigning it a new IP) and leave it running for as long as you need reporting.
    You would then need a new server to run your upgraded V6 CCM; you may find you need this anyway.
    Regards
    Aaron
    Please rate helpful posts...

  • I am moving from PC to Mac.  My PC has two internal drives and I have a 3Tb external.  What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data

    I am moving from PC to Mac.  My PC has two internal drives and I have a 3Tb external.  What is best way to move the data from the internal drives to Mac and the best way to make the external drive read write without losing data

    Paragon even has non-destriuctive conversion utility if you do want to change drive.
    Hard to imagine using 3TB that isn't NTFS. Mac uses GPT for default partition type as well as HFS+
    www.paragon-software.com
    Some general Apple Help www.apple.com/support/
    Also,
    Mac OS X Help
    http://www.apple.com/support/macbasics/
    Isolating Issues in Mac OS
    http://support.apple.com/kb/TS1388
    https://www.apple.com/support/osx/
    https://www.apple.com/support/quickassist/
    http://www.apple.com/support/mac101/help/
    http://www.apple.com/support/mac101/tour/
    Get Help with your Product
    http://docs.info.apple.com/article.html?artnum=304725
    Apple Mac App Store
    https://discussions.apple.com/community/mac_app_store/using_mac_apple_store
    How to Buy Mac OS X Mountain Lion/Lion
    http://www.apple.com/osx/how-to-upgrade/
    TimeMachine 101
    https://support.apple.com/kb/HT1427
    http://www.apple.com/support/timemachine
    Mac OS X Community
    https://discussions.apple.com/community/mac_os

  • HT1386 I am having problem syncing my itunes data from my computer to my ipod and ipad. My data is not fully transferred.  Can someone help me?

    I am having problems syncing my itunes data from my computer to my ipod and ipad.  The data from my computer is not transferring.  Can someone help me?

    What happens when you try to sync?
    Does any media sync?
    Was the iPod previous synced to another iTunes library/computer?
    Have you successfully synced from this iTunes library/computer before?
    Do the songs play in iTunes?
    Do you have the right boxes checked to sync?
    iTunes: Syncing media content to iOS devices and iPod        

  • SQL query to fetch records  from  26 onwards

    Want to know SQL query to fetch records from 26 onwards.

    See the fifth entry on the FAQ page:
    Re: How to attach a java bean in forms6i

  • HT204350 Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier"

    Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier". Should be http://support.apple.com/kb/HT6025

    I think the OP is saying OS X: How to migrate data from another Mac using Mountain Lion and earlier (which should be a link to HT4889) just links back to OS X: How to migrate data from another Mac using Mavericks (HT5872).
    It does indeed do that, & HT4889 seems to be MIA.

  • I've got the labview vi written to read my IMU data from a serial port in COM1 and it displays onto the table on the front panel. I'm having trouble getting this data onto an excel spreadshee​t. Any ideas?

    I've got the labview vi written to read my IMU data from a serial port in COM1 and it displays onto the table on the front panel. I'm having trouble getting this data onto an excel spreadsheet. Any ideas? Right now my data will collect one reading instead of continuously reading my IMU which displays data in a continuous stream.
    Thanks
    Attachments:
    Read_IMU_Drew.vi ‏21 KB

    Hi
    Your vi is in 2009 version, which i am unable to open in 8.6
    However, if you want your data to be saved in excel sheet, here is the VI
    Somil Gautam
    Think Weird
    Attachments:
    save to excel.vi ‏12 KB

  • Need to download the data from BSEG based on company code and fiscal year

    Hi All,
              Please suggest me the solution to download the data from BSEG based on company code and fiscal year. As data in BSEG for the fiscal year2009  is 27 lakhs (= 2.7 million) for the specified company code.
    <removed>
    Thanks & Regards,
    Koti
    Edited by: Thomas Zloch on Mar 26, 2010 4:28 PM - please use English metrics only!

    May I ask what you mean by solution?  You can download from SE11, but where are you going to store 2.7 million rows and what tool are you going to use to store it?
    You probably need a (small) program that extracts what you want, then opens a dataset in an appropiate server-system folder, and transfers the data rows to the dataset as fixed-length or tab-delimited file.  It's been done many times, so suggest that you search.

  • Sql query to get numbers from 0 to 99

    How can we write an sql query to get values from 0 to 99 ... this shouldn't be coming from any table

    Bawer wrote:
    Result: (quickly replied by oracle)
    SQL-Error: ORA-30009 (Not enough memory for connect by - 1GB reserved for oracle on VirtualBox)Oracle version? Takes about 8 seconds on my:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Elapsed: 00:00:00.14
    SQL> select count(*) from (
      2  SELECT LEVEL - 1
      3  FROM DUAL
      4  CONNECT BY LEVEL <= 10000000
      5  )
      6  /
      COUNT(*)
      10000000
    Elapsed: 00:00:07.76
    SQL> SY.

  • I transfered my data from icloud onto my new ipad and one of my games didn't back up as i saved it initially. I have to start all over is this normal

    I transferred my data from icloud onto my new ipad and one of my games didn't back up as i saved it initially. I have to start all over is this normal

    You can't merge the backups, you'll have to delete the backup of your old phone.  If it says it's currently in use when you try, that will normally clear up on its own but may take 3-5 days to do so.  Give it a few days and try deleting the old backup again.
    In the meantime, you can create a manual backup of your new phone on your computer by connecting it to your computer, opening iTunes, clicking on the name of your phone in iTuens, going to the Summary tab of your iTunes sync settings and clicking Back Up Now.  Also go to File>Devices>Transfer Purchases.  Then you'll be safe until you can start backup up to iCloud again.

  • Is there any deffirence for master data from flat fime bi 7.0 and 3.5?

    hi friends,
    is there any deffirence for master data from flat fime bi 7.0 and 3.5?
    regards
    suneel.

    you can follow the same 3.x dataflow eventhough u upgrade.
    the only diff
    3.x - would be emulated DS
    7.0 - RSDS
    3.x - file path declared in infopack
    7.0 - is declared in DS (that would be inherted by infopack)
    Infosource - optional - works fine on both the versions
    creating a new DS, it has to be RSDS .. no way out

  • Am unable to transfer/sync my "Notes" data from iPhone 6 to my MacAir and MacMini PC. Just doesn't work. Please advise.

    Am unable to transfer/sync my "Notes" data from iPhone 6 to my MacAir and MacMini PC. Just doesn't work. Please advise.
    regards / krishnakumar
    Cochin/India

    There may be other ways, but the best way I've found is:
    Set up an iCloud email account so that you can use the Notes part of this service.  Note that I said "iCloud email" not "iCloud" ... you need to enable the email service of iCloud in order to get the iCloud Notes feature.  Otherwise, the "Notes" app on your device will only store notes on your device, or maybe sync them with some other email account (e.g. Gmail, Yahoo ... but does so poorly IMO).
    On your Macs, set up the same iCloud account as on your iPhone.  Now that you've set up the email part of iCloud, you can enable the Notes feature of iCloud on your Macs.
    Be sure to set iCloud as the default account to store your notes, in case you have other email services with a Notes feature.
    New notes that you create on any device will sync to each other.
    Notes that you created before doing all this cannot sync to your Macs, since the notes were not in iCloud.  Just turning on iCloud Notes does not cause them to enter iCloud and sync -- you'd have to copy and paste them into a new note, after ensuring that iCloud is the default account for any new notes.

  • HT4967 I can sync data from my Mac to my iPhone and iPad and from my iPhone to the Mac and iPad, but cannot sync data from the iPad to either device. My iPad is configured to Push. Is there another setting than I'm forgetting?

    I can update data from my Mac to my iPhone and iPad, and from my iPhone to my Mac and iPad, but cannot get data to update from my iPad to either my Mac or my iPhone.

    If new calendar events entered on your iPad do not appear on icloud.com, go to Settings>Mail,Contacts,Calendars>Default Calendar on your iPad and be sure you have selected an iCloud calendar as your default and not something else like On My iPhone, a Gmail or Yahoo calendar, etc.  If you haven't, make this change, then add a new event and see if it appears on your calendar on icloud.com now.
    If your settings are correct and new events still aren't appearing on icloud.com, add any missing calendar events from your iPad to your calendar on icloud.com.  Once the calendar on icloud.com is up to date with your iPad, go to Settings>iCloud, turn Calendars to Off, choose Delete from My iPad when prompted (they will still be in iCloud), then after a 15 seconds or so, turn Calendars back to On.  Then add a new event on your iPad and see if it appears on your calendar on icloud.com now, and on your other devices.

  • Ok, so I want to buy the new iPod touch 5g this week and I have an iPhone 4. I want to transfer all the data from the phone to the iPod and have the files the exact same. I don't want to redo data, say erase game data (campaigns, achievements)...

    Ok, so I want to buy the new iPod touch 5g this week and I have an iPhone 4. I want to transfer all the data from the iPhone to the iPod and have the files the exact same. I don't want to redo data, say erase game data (campaigns, achievements)... I have apps that have very important data on them and if I sync it to iTunes and then transfer all that data to the iPod Touch 5g, will that erase app data?

    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device

Maybe you are looking for

  • ITunes 7.0.2 works finally!

    I've done my share of moaning, complaining and bad mouthing the latest iTunes. I'm still disappointed at the time and effort it took to install. It should not take an advanced or intermediate user to install this program. These are the programs I use

  • Validation on Integer data type attribute

    Hi, Working on jdev 11.1.1.3.0 I have to do validation on integer data type like, it should not allow 13.20(only single digit numbers.). I am doing validation on AMImpl and converting the int into string String per=Row.getPer().toString();// here if

  • Tomcat 5.0.18 Servlets

    I am new to JSP, installed J2SDK1.4.2_03 and Tomcat 5.0.18. I am able to get the jsp pages to work and also view the sample servlet examples. But I am having a hard time getting my servlets to work. I have set the ClassPath to C:\Jakarta\Jakarta-tomc

  • Encoding HDV material

    Is everyone writing their edited HDV movies back to tape? I have been playing HDTV movies from computers for the last 10 years. I can play my MPEG2 TS encoded 720p or 1080i movies smoothly on my 17" 1.3 GHz Powerbook using the VideoLan (VLC) app and

  • My iPhone say it need to cool down before using it

    My iPhone have4 days say it need to cool down before using